Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Sign in to follow this  
Followers 0
footballking3420

FOR Loop in Linux Help

3 posts in this topic

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

0

Share this post


Link to post
Share on other sites

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?).

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.