EN
Bash - capture all arguments passed from command line (regardless of their number)
0 points
In this article, we would like to show you how to capture all arguments passed from command line in Bash.
In this example, we use "$@"
to capture all arguments passed from command line. Then we iterate through all parameters using for loop and print them using echo command.
xxxxxxxxxx
1
2
3
for parameter in "$@"
4
do
5
echo "$parameter"
6
done
Run in command line:
xxxxxxxxxx
1
./script.sh one two three
Output:
xxxxxxxxxx
1
one
2
two
3
three