Command Line Help!!!!!!!!!!!

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help

Command Line Help!!!!!!!!!!!

Postby linuxuser0667 on Mon Jun 16, 2014 4:26 pm

basically, I have a shell script that I made and I just need someone to look over it to make sure its doing what I am required it to do plase help me thanks!
This is the shell script I have:
Code: Select all
#!/bin/bash
#while [[ $# -lt 2 || $# -eq 1 ]]
   #do'

until [[ $x == 999 ]]
   do

if test $# -lt 2

then
   if [[ $# -eq 1 ]]

   then
      x=$1   
   echo -n "Enter a value for y: "
   read y

else
   echo -n "Enter a value for x: "
   read x
   
   echo -n "Enter a value for y: "
   read y

fi
else
   x=$1
   y=$2
fi
echo "x = $x"
echo "y = $y"

((q=y/x))
echo "y/x = $q"

((r=y%x))
echo "y%x = $r"
done
done


AND THIS IS WHAT IT NEEDS TO DO:
. The script needs to perform the following pseudocode in the order shown:
Prompt the user to enter a value for a variable named x
Print (display) the value.
Prompt the user to enter a value for a second variable named y
Print (display) the value.
Divide y by x and place the result into variable q.
Print (display) q.
Calculate the remainder of y divided by x and place the result into the variable r.
Print (display) r.
3. Be sure to test the value for x to avoid dividing by zero.
Give the user the option of specifying the x and y values on the command line. If they're present, use them. If not, prompt for the user to enter them.
Give the user the option of specifying the x and y values on the command line. If they're present, use them. If both are missing, prompt for the user to enter both. If only one is supplied, use it for x, and prompt the user to enter a second value for y.
Modify it by incorporating the loops and if statements.
Last edited by karlchen on Mon Jun 16, 2014 6:32 pm, edited 1 time in total.
Reason: Added [code] [/code] tags around the script. Makes reading easier.
linuxuser0667
Level 1
Level 1
 
Posts: 4
Joined: Wed May 21, 2014 2:14 pm

Linux Mint is funded by ads and donations.
 

Return to Other topics

Who is online

Users browsing this forum: No registered users and 3 guests