AGE=`cat ${USERNAME}_DAT
#!/bin/sh
# Prompt for a user name... echo "Please enter your name:" read USERNAME # Check for the file. if [ -s ${USERNAME}_DAT ]; then # Read the age from the file. AGE=`cat ${USERNAME}_DAT` echo "You are $AGE years old!" else # Ask the user for his/her age echo "How old are you?" read AGE if [ "$AGE" -le 2 ]; then echo "You are too young!" else if [ "$AGE" -ge 100 ]; then echo "You are too old!" else # Write the age to a new file. echo $AGE > ${USERNAME}_DAT fi fi fi In this program what is AGE=`cat ${USERNAME}_DAT and how it work ..... |
Honestly, this seems like homework.... Can't you see what it is? This is a bash script, and just by looking at it, I can see what it is, and what it does.
|
Please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
Actually, it's not a bash script. Since it begins with #!/bin/sh, and doesn't contain any bash-specific syntax, it's just a generic posix-compliant script. Still, everything written there should be covered in just about any bourne-compatible shell tutorial out there. Here's my favorite: http://mywiki.wooledge.org/BashGuide BTW, $(..) is highly recommended over `..`. ;) |
Oops, my fault. It's a shell script ;) Thanks for the correction though! I read it too fast.....
|
Code:
AGE=`cat ${USERNAME}_DAT` |
To see what's going on, amend the top of the script
Code:
#!/bin/sh Useful links http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ Note that 'sh' & 'bash' are different shells, but very similar. To fully take advantage of those links, use bash instead of sh. |
All times are GMT -5. The time now is 03:56 AM. |