Command Line Arguments like $# or $1.. how to increment?- Bourne Shell

Let's say the script is called

and i run it so it's like " a b c d e f"

I'm trying to print it so it prints something like
a b c d e f
b c d e f
c d e f

I'm trying something like maybe incrementing $1.. so i can do something like

num=`expr $1 + 1`
echo num

but that isn't working... i'm still not sure how i can code this yet, but I'm thinking if I can increment $1, i can figure something out.. is there some way I can do this?

I know of the $# and $@ but I don't think it helps very much.. i'm hoping someone can push me in the right direction
Who is Participating?
ozoConnect With a Mentor Commented:
while [ $# -gt 0 ] ; do
  echo $*
woolmilkporcConnect With a Mentor Commented:

you can use "shift", which will drop $1, make $2 to $1, $3 to $2 etc.

There is also "shift 2", "shift 3" etc.


nocturn4lAuthor Commented:
life saver
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.