使用shift命令.sh Shell 脚本

Shell 片段 · codes/shell/输入和输出/使用shift命令.sh · 19 行

源码

#!/usr/bin/env bash

# shift n 移动变量

count=1
while [ -n "$1" ]
do
	echo "Parameter #$count = $1"
	count=$[ $count + 1 ]
	shift
done

echo -e "\n"

# demonstrating a multi-position shift
echo "The original parameters : $*"
shift 2
echo "Here's the new first parameter: $1"

查看上游源码 ↗

内容与示例整理自 dunwu/linux-tutorial,遵循 CC BY-SA 4.0;本站保留原作者署名与许可,命令仅供学习,执行前请核对目标环境。