📄 arglist.sh
字号:
#!/bin/bash# arglist.sh# Invoke this script with several arguments, such as "one two three".E_BADARGS=65if [ ! -n "$1" ]then echo "Usage: `basename $0` argument1 argument2 etc." exit $E_BADARGSfi echoindex=1 # Initialize count.echo "Listing args with \"\$*\":"for arg in "$*" # Doesn't work properly if "$*" isn't quoted.do echo "Arg #$index = $arg" let "index+=1"done # $* sees all arguments as single word. echo "Entire arg list seen as single word."echoindex=1 # Reset count. # What happens if you forget to do this?echo "Listing args with \"\$@\":"for arg in "$@"do echo "Arg #$index = $arg" let "index+=1"done # $@ sees arguments as separate words. echo "Arg list seen as separate words."echoindex=1 # Reset count.echo "Listing args with \$* (unquoted):"for arg in $*do echo "Arg #$index = $arg" let "index+=1"done # Unquoted $* sees arguments as separate words. echo "Arg list seen as separate words."exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -