Help - Search - Members - Calendar
Full Version: FOR Loop in Linux Help
MSFN Forums > Software, Hardware, Media and Games Central > Other Operating Systems

   


Google Internet Forums Unattended CD/DVD Guide
footballking3420
This is what I have so far:

CODE
COUNT=0
echo "You have entered $# arguments:"
for ARG in $*
do
echo "#`expr $COUNT + 1`: $ARG"
done


I can't seem to get the COUNT variable to increase for each listed argument. For example, if I enter something like:

CODE
./FILE_NAME one two three


I ended up getting this:

CODE
You have entered 3 arguments:
#1: one
#1: two
#1: three
Zxian
Normally, we don't help with homework (see Forum Rules #2c)... but I'll give you a small hint - look at what you're doing with count... you're simply adding one to the existing value and displaying the result (what happens to $COUNT after it's executed?).
footballking3420
Oh, I got it now. I had to add COUNT=`expr $COUNT + 1` as a second statement.




Google Internet Forums Unattended CD/DVD Guide

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.