Skip to main content
added 171 characters in body
Source Link

While # on it's own is definitely a comment, $# contains the number of parameters passed to your function.

test is an program which lets you perform various tests, for example, if one number is greater than another number (if your operator is -gt; there are many other operators, see man test). It will return success if the the test is successful (in this case, if the number of parameters IS greater than 0).

the shift command throws away the first parameter. It also decreases $#

The code as a whole can be seen as: do something with a parameter (in this case, showing it on the screen), then discard it; repeat until there are no parameters left.

If you want to see all the parameters that are left, useful for debugging, check the contents of $@

While # on it's own is definitely a comment, $# contains the number of parameters passed to your function.

test is an program which lets you perform various tests, for example, if one number is greater than another number (if your operator is -gt; there are many other operators, see man test). It will return success if the the test is successful (in this case, if the number of parameters IS greater than 0).

the shift command throws away the first parameter. It also decreases $#

While # on it's own is definitely a comment, $# contains the number of parameters passed to your function.

test is an program which lets you perform various tests, for example, if one number is greater than another number (if your operator is -gt; there are many other operators, see man test). It will return success if the the test is successful (in this case, if the number of parameters IS greater than 0).

the shift command throws away the first parameter. It also decreases $#

The code as a whole can be seen as: do something with a parameter (in this case, showing it on the screen), then discard it; repeat until there are no parameters left.

If you want to see all the parameters that are left, useful for debugging, check the contents of $@

Source Link

While # on it's own is definitely a comment, $# contains the number of parameters passed to your function.

test is an program which lets you perform various tests, for example, if one number is greater than another number (if your operator is -gt; there are many other operators, see man test). It will return success if the the test is successful (in this case, if the number of parameters IS greater than 0).

the shift command throws away the first parameter. It also decreases $#