I would like to write a bash script with unknown amount of arguments.
How can I walk through these arguments and do something with them?
A wrong attempt would look like this:
#!/bin/bash
for i in $args; do
echo $i
done
|
There's a special syntax for this:
More generally, the list of parameters of the current script or function is available through the special variable
Note that you need the double quotes around
|
|||
|
You should quote
That's two arguments rather than three, due to the quotes. If you don't quote |
|||||
|