Semicolon on command line in linux

2019-04-04 18:03发布

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,

 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

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.

标签: linux bash shell
1条回答
爷的心禁止访问
2楼-- · 2019-04-04 18:52

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

./command 123\;456\;5464

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

./command '123;456;5464'
查看更多
登录 后发表回答