bash $1

environment variable "$1", which referred to the first command-line argument. Similarly, you can use "$2", "$3", etc. to refer to the second and third arguments passed to your script.
ex
#!/usr/bin/env bash

echo name of script is $0
echo first argument is $1
echo second argument is $2
echo seventeenth argument is $17
echo number of arguments is $#

bash features the "$@" variable, which expands to all command-line parameters separated by spaces.

"$0" will expand to the name of the script, as called from the command line,

"$#" will expand to the number of arguments passed to the script.

posted @ 2011-06-04 07:32  greencolor  阅读(431)  评论(0)    收藏  举报