Linux shell中如何处理10个以上的参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4912733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:17:40  来源:igfitidea点击:

How to handle more than 10 parameters in shell

linuxbashshellparameters

提问by Ashitosh

I am using bash shell on linux and want to use more than 10 parameters in shell script

我在 linux 上使用 bash shell 并且想在 shell 脚本中使用 10 多个参数

采纳答案by Paused until further notice.

Use curly braces to set them off:

使用花括号来设置它们:

echo ""

You can also iterate over the positional parameters like this:

您还可以像这样迭代位置参数:

for arg

or

或者

for arg in "$@"

or

或者

while (( $# > 0 ))    # or [ $# -gt 0 ]
do
    echo ""
    shift
done

回答by lukuluku

You can have up to 256 parameters from 0 to 255 with:

您最多可以有 256 个从 0 到 255 的参数:

${255}