Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

FOR Loop in Linux Help

- - - - -

  • Please log in to reply
2 replies to this topic

#1
footballking3420

footballking3420

    Horror & Metal purist

  • Member
  • PipPip
  • 119 posts
This is what I have so far:

 
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:

 
./FILE_NAME one two three 


I ended up getting this:

 
You have entered 3 arguments:
#1: one
#1: two
#1: three



How to remove advertisement from MSFN

#2
Zxian

Zxian

    Scroll up - see the Google bar?

  • Super Moderator
  • 5,066 posts
  • OS:none specified
  • Country: Country Flag
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?).

#3
footballking3420

footballking3420

    Horror & Metal purist

  • Member
  • PipPip
  • 119 posts
Oh, I got it now. I had to add COUNT=`expr $COUNT + 1` as a second statement.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN