linux命令行中的分号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20233934/
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-07 01:27:55  来源:igfitidea点击:

Semicolon on command line in linux

linuxbashshell

提问by ramulu ponnam

i am running my application in linux by providing inputs as command line. My input field contain an argument which contains ";"(semicolon) internally.(For example:123;434;5464). This will be parsed using UTF8String encode and send. But when i am using like this, in initial itself i am getting,

我通过提供输入作为命令行在 linux 中运行我的应用程序。我的输入字段包含一个内部包含“;”(分号)的参数。(例如:123;434;5464)。这将使用 UTF8String 编码和发送进行解析。但是当我像这样使用时,最初我得到,

 bash: 434: command not found
 bash: 5464: command not found

And when i capture traffic the output contains only 123 instead 123;434;5464 But if i give without semicolon (Ex:123:434:5464),not getting any problem output coming properly as 123:434:5464

当我捕获流量时,输出仅包含 123 而不是 123;434;5464 但是如果我不带分号(例如:123:434:5464),则没有任何问题输出正确为 123:434:5464

Point me how to give command line input by using semicolon as to come output. Is there any particular syntax to use while doing with semicolon. I am running like below

指出如何通过使用分号作为输出来提供命令行输入。使用分号时是否有任何特定的语法可以使用。我像下面一样运行

./runASR.sh -ip 10.78.242.4 -port 3868 -sce 10.78.241.206 -id 85;167838865;1385433280

where -id field contain that value with issue.

其中 -id 字段包含该值有问题。

回答by Shiplu Mokaddim

;is treated an end of commandcharacter. So 123;456;5464to bash is in fact 3 commands. To pass such meta-characters escape it with escape character \.

;被视为命令结束符。所以123;456;5464bash 实际上是 3 个命令。要传递此类元字符,请使用转义字符对其进行转义\

./command 123\;456\;5464

Or Just quote it with single quote (double quote evaluates the inner string) (Thanks Triplee, I forgot to mention this)

或者只用单引号引用它(双引号计算内部字符串)(感谢 Triplee,我忘了提到这一点)

./command '123;456;5464'