A list of all the parameters, in a single varible, separated by the first character in the environment variable IFS. If IFS is modified,
then the way $* separates the command line into parameters will change.
IFS=:
set foo bar bam
echo "$*"
IFS=~~
echo "$*"
#!/bin/bash
salutation="hello"
echo $salutation
echo "程序 $0 正在运行"
echo "第2个参数是: $1"
echo "第3个参数是: $2"
echo "参数列表为 $* "
echo ""
echo "修改一下 IFS 变量(分隔符用 : 号来显示)"
IFS=':'
echo ""
echo "第2个参数是: $1"
echo "第3个参数是: $2"
echo "参数列表为 $* "
echo "\\$@ 的输出:$@"
echo ""
echo -n "Please enter a new greeting:"
read salutation
echo $salutation
echo "The script is now complete"
exit 0
[beyes@localhost shell]$ ./parameter-envar.sh -p1 -p2 -p3
hello
程序 ./parameter-envar.sh 正在运行
第2个参数是: -p1
第3个参数是: -p2
参数列表为 -p1 -p2 -p3
修改一下 IFS 变量(分隔符用 : 号来显示)
第2个参数是: -p1
第3个参数是: -p2
参数列表为 -p1:-p2:-p3
$@ 的输出:-p1 -p2 -p3 #这里仍然以空格分开
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |