开发者

Display octal value without being interpreted with tr?

开发者 https://www.devze.com 2023-02-07 21:36 出处:网络
I have ./script \"test\\42\" Here is an example script : #!/bin/sh echo \"$1\" It gives me : test\" (42 being interpreted as an ASCII octal value, 42 = \")

I have

./script "test\42"

Here is an example script :

#!/bin/sh
echo "$1"

It gives me :

test" (42 being interpreted as an ASCII octal value, 42 = ")

How can I do to display

test\42 (instead test" ?)

With the help of tr (tr开发者_运维百科anslate Unix command)?


Try either using single quotes:

./script 'test\42'

or escaping the slash:

./script "test\\42"
0

精彩评论

暂无评论...
验证码 换一张
取 消