How to skip the first argument in a script

Linux Pocket Guide has a nice example on how to go over all the arguments in a script

for arg in [email protected]
do
   echo "I found the argument $arg"
done

I am writing a script in which all the arguments will be text files, and I will concatenate all those text files and print them to stdout, however I should exclude the contents of the first argument. My first approach would be something like this

for arg in [email protected]
do
   cat "$arg"

done

However, that will include the first argument, and as I mentioned, I want to print all except the first one.

Answer

You can use shift command like this:

shift
for arg in "[email protected]"
do
    cat "$arg"
done 

Leave a Reply

Your email address will not be published. Required fields are marked *