Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.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 如何找到从$@传递到脚本中的最后一个参数?_Bash - Fatal编程技术网

Bash 如何找到从$@传递到脚本中的最后一个参数?

Bash 如何找到从$@传递到脚本中的最后一个参数?,bash,Bash,这不是我想要的:last_arg=“${!#}”我认为${@:-1:1}(空格是必需的,否则它会感到困惑并认为您使用的是默认设置)会这样做;与下标不同,slice语法允许从数组末尾开始索引负数 请提供更多信息?如果您知道您应该获得3个参数,为什么不port=$3? #!/bin/bash /home/someDir/myServer $@ #arguments go as follow: ./server IP SERVICE PORT port = $@ ? echo "your p

这不是我想要的:last_arg=“${!#}”

我认为
${@:-1:1}
(空格是必需的,否则它会感到困惑并认为您使用的是默认设置)会这样做;与下标不同,slice语法允许从数组末尾开始索引负数

请提供更多信息?如果您知道您应该获得3个参数,为什么不
port=$3
#!/bin/bash 

/home/someDir/myServer $@

#arguments go as follow: ./server IP SERVICE PORT

port = $@ ?

echo "your port "$port