Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bash:将参数从3美元起传递给另一个程序(比如tar)_Bash - Fatal编程技术网

bash:将参数从3美元起传递给另一个程序(比如tar)

bash:将参数从3美元起传递给另一个程序(比如tar),bash,Bash,假设我的脚本采用从$3开始的文件名 e、 g 我想从3美元开始压缩列出的所有文件 我该怎么做 谢谢bash命令shift是您的朋友 脚本example.sh #!/bin/bash shift 3 echo $* 使用example.sh 1 2 3 4 5调用将输出4 5 zip archivename.zip "${@:3}" 输入: ./test.sh 1 2 3 4 5 输出: 1 2 tar cf archive.tar 3 4 5 这比使用shift更通用 ./test.sh

假设我的脚本采用从$3开始的文件名

e、 g

我想从3美元开始压缩列出的所有文件 我该怎么做


谢谢

bash命令
shift
是您的朋友

脚本
example.sh

#!/bin/bash
shift 3
echo $*
使用
example.sh 1 2 3 4 5
调用将输出
4 5

zip archivename.zip "${@:3}"
输入:

./test.sh 1 2 3 4 5
输出:

1
2
tar cf archive.tar 3 4 5

这比使用shift更通用
./test.sh 1 2 3 4 5
1
2
tar cf archive.tar 3 4 5