Remove first element from $@ in bash

Posted by Herms on Stack Overflow See other posts from Stack Overflow or by Herms
Published on 2010-04-23T19:26:04Z Indexed on 2010/04/23 19:33 UTC
Read the original article Hit count: 292

Filed under:
|

I'm writing a bash script that needs to loop over the arguments passed into the script. However, the first argument shouldn't be looped over, and instead needs to be checked before the loop.

If I didn't have to remove that first element I could just do:

for item in "$@" ; do
  #process item
done

I could modify the loop to check if it's in its first iteration and change the behavior, but that seems way too hackish. There's got to be a simple way to extract the first argument out and then loop over the rest, but I wasn't able to find it.

© Stack Overflow or respective owner

Related posts about bash

Related posts about arrays