Pomario Asked: 2012-04-25 10:39:50 +0800 CST2012-04-25 10:39:50 +0800 CST 2012-04-25 10:39:50 +0800 CST How to loop through arguments in Bash ($1 $2 $3 and so forth)? 772 I have the following code snippet for num do echo $num done But I don't understand why it works! How come does Bash know to loop through my params $1, $2, $3, $... using my personal taste of "num" variable??? scripts bash 1 Answers Voted Best Answer glenn jackman 2012-04-25T10:57:38+08:002012-04-25T10:57:38+08:00 It's a feature of bash: for num; do ... is a shorthand for for num in "$@"; do ... The documentation is at http://www.gnu.org/software/bash/manual/bashref.html#Looping-Constructs
It's a feature of bash:
is a shorthand for
The documentation is at http://www.gnu.org/software/bash/manual/bashref.html#Looping-Constructs