Computing.Net > Forums > Unix > read in arguments

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.

read in arguments

Reply to Message Icon

Name: naruto
Date: December 10, 2003 at 20:13:28 Pacific
OS: linux
CPU/Ram: pentium 4
Comment:

I want to read in arguments from command line and store that in a variable.

so I have a program call mycal, and it takes in many arguments:

mycal jan - jun 2004 aug 1992

so I want to read in all those arguments, when it sees the dash '-', sets a flag, and store the previous argument "jan" and the next argument "jun" into the variable. I already have another script that translate jan to 1 and jun to 6, etc..

for example,

the var MONTH would have { 1 2 3 4 5 6 }

this is what I have so far:

for m in $*
do
ARG=`name2num $m`
echo $ARG
if test $m = -
then
DASH=TRUE
elif test $ARG != error && DASH == TRUE
MONTH = "$MONTH $ARG"
fi
done


Thanks.



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: read in arguments

how to read in an external text fil www.computing.net/answers/unix/how-to-read-in-an-external-text-fil/3757.html

Read in Korn Shell www.computing.net/answers/unix/read-in-korn-shell/5141.html

deleting rows in a file www.computing.net/answers/unix/deleting-rows-in-a-file/3676.html