--- [EMAIL PROTECTED] wrote:
> Brad De Vries wrote,
> > You could try:
> > ---------
> > TOTCNT=$#
> > for ((NUM=1; NUM <= $TOTCNT; NUM++))
> > do
> >   echo "$NUM: $1"
> >   shift
> > done
> > ---------
> 
> Wouldn't this kind of leave me stuck if I were to
> want to do something
> with any of the parameters later on?  I notice from
> the man page that you
> can't shift them back.
> 
> Thanks for the suggestion.
> 
> David Aikema

You are correct, you cannot shift the positional
parameters back onto the stack once they've been
shifted off.  I didn't realize that you wanted to
retain their position for use later on.  In that case,
I would take one of the other suggestions and simply:

#!/bin/sh
NUM=0
for i in $*; do
  let NUM=$NUM+1
  echo "$NUM: $i"
done

You might also be able to use the 'eval' builtin
command.

Brad.

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
_______________________________________________
Linux-users mailing list
[EMAIL PROTECTED]
Unsubscribe/Suspend/Etc -> http://www.linux-sxs.org/mailman/listinfo/linux-users

Reply via email to