显示八进制值而不用tr解释?

时间:2011-01-28 22:09:28

标签: scripting sh

我有

./script "test\42"

以下是一个示例脚本:

#!/bin/sh
echo "$1"

它给了我:

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

如何显示

test\42 (instead test" ?)

借助tr(翻译Unix命令)?

1 个答案:

答案 0 :(得分:0)

尝试使用单引号:

./script 'test\42'

或逃避斜线:

./script "test\\42"