Help making simple script
I would really appreciate some help with this script I am trying to make. If someone could help me, I would really appreciate it. Thank you.
The script needs to ask the users name and age and then output one of the below two statements depending on their age. "Name" you are old enough to purchase alcohol. "Name" you are not old enough to purchase alcohol. After this the script needs to output today's date. Then it should ask if the user would like to create a directory. If they enter a y for yes then it should ask for the absolute path of the directory and create it for them. |
Any help would be greatly appreciated. I could really use it.
|
Mmm, is this homework? Coz it's really simple. You could easily do it yourself if you tried. I mean very easily. CLick here to begin.
|
This is one of MANY homework assignments I have that deal with bash scripts. If someone could just help me out with this one, you would be helping me more than you could imagine.
|
You'll probably need to use the 'date' command, so I would look at the man page or look it up online.
|
Anyone with more help please??
|
Hi,
you won't need to use the date command. You'll need to use "read" to get input from the user, then an "if" statement to determine if what to output and then "echo" to write the output to the terminal. Telling you any more than that would essentially be doing your homework for you, and if we do that you won't really be learning, and you won't be able to do any of your more difficult homework. So, do some reading (presumably you have course notes, and the link posted by DJ Shaji looks good) and then try to write the script. If you have problems, show us what you have done, explain the problem and we can make suggestions to help you. Cheers, Evo2. |
Bash is real simple buddy. There will come a day when your code will segfault, and you'll be tearing your hair out :p
|
Using the 'date' command can simplify the calculation, which can be complex.
Some examples, but not exactly what you want: http://unix.stackexchange.com/questi...te-differences http://stackoverflow.com/questions/5...date-variables http://stackoverflow.com/questions/8...urs-bash-shell |
Hi,
Quote:
Code:
if [ $age -ge $legal_dring_age ] ; then |
This is a good link http://rute.2038bug.com/index.html.gz.
As mentioned above though, read those links, then start writing your own code and come back if you get stuck. |
He needs to output the date. How would date help in calculations ?
|
Quote:
There are over one MILLION hits in Google for "bash scripting tutorial". The three best are: http://www.tldp.org/LDP/Bash-Beginners-Guide/html/ http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html http://www.tldp.org/LDP/abs/html/ All complete with examples and full explanations. Start there. |
Quote:
|
Hi,
Quote:
Quote:
Evo2. |
All times are GMT -5. The time now is 12:08 AM. |