Computing.Net > Forums > Unix > Shell scripts - please help!!!!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell scripts - please help!!!!

Reply to Message Icon

Name: Daon
Date: May 5, 2003 at 18:51:59 Pacific
OS: Windows
CPU/Ram: Pentium 4 256 MB
Comment:

Please help...I'm very new to Unix.
I need a script (myscript)that takes the command line arguments and displays like:

%myscript John Smith

%Hello John
%Your last name is: Smith


And another script (myage) that subtracts the age (that's supplied as a command line argument)from the year 2003:

%myage 13
%Were you born in 1990?

Many Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: May 5, 2003 at 20:31:42 Pacific
Reply:

#!/bin/sh
if [ $# -ne 2 ] ; then
echo "Error. Usage $0 firstname lastname"
exit 4
else
echo "Hello $1"
echo "Your last name is $2"
fi
-----------------------
#!/usr/local/bin/ksh
if [ $# -ne 1 ] ; then
echo "Error. Usage $0 age "
exit 4
else
YEAR=`date +%Y`
((birthyear = $YEAR - $1))
echo "Were you born in $birthyear?"
fi


0

Response Number 2
Name: LANkrypt0
Date: May 6, 2003 at 05:30:12 Pacific
Reply:

This sounds a lot like home work :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell scripts - please help!!!!

Read file and replace..shell script www.computing.net/answers/unix/read-file-and-replaceshell-script/5083.html

About Shell script - Need help www.computing.net/answers/unix/about-shell-script-need-help-/5796.html

shell script to write mails. www.computing.net/answers/unix/shell-script-to-write-mails/6267.html