linux-tutorial/codes/shell/输入和输出/使用shift命令.sh

19 lines
280 B
Bash
Raw Normal View History

2019-10-29 18:22:19 +08:00
#!/usr/bin/env bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
# shift n 移动变量
count=1
while [ -n "$1" ]
do
2019-10-29 18:22:19 +08:00
echo "Parameter #$count = $1"
count=$[ $count + 1 ]
shift
2019-05-10 11:17:57 +08:00
done
echo -e "\n"
# demonstrating a multi-position shift
echo "The original parameters : $*"
shift 2
echo "Here's the new first parameter: $1"