EN
Bash - omit first argument from command line
3 points
In this article, we would like to show you how to omit first argument from command line in Bash.
In this example, we use "${@:2}"
to capture all arguments passed from command line starting from the second argument. Then we iterate through all parameters using for loop and print them using echo command.
Example script.sh
file:
xxxxxxxxxx
1
2
3
for argument in "${@:2}"
4
do
5
echo "$argument"
6
done
Run in the command line:
xxxxxxxxxx
1
./script.sh one two three
Output:
xxxxxxxxxx
1
two
2
three