For Loop without a list-of-words parameter
suggest changefor arg; do
echo arg=$arg
done
A for
loop without a list of words parameter will iterate over the positional parameters instead. In other words, the above example is equivalent to this code:
for arg in "$@"; do
echo arg=$arg
done
In other words, if you catch yourself writing for i in "$@"; do ...; done
, just drop the in
part, and write simply for i; do ...; done
.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents