如何在Linux bash shell中逃避bang(!)字符?

Nic*_*ick 15 linux bash shell

我不能为我的生活弄清楚如何逃避!Bash中的角色.例如,我想打印这个:

Text text text!

我试过这个:

echo "Text text text\!"
Run Code Online (Sandbox Code Playgroud)

但是这会打印出来:

Text text text\!

(带有额外的反斜杠).

我怎样才能做到这一点?

Cyr*_*rus 18

试试这个:

 echo 'Text text text!'
Run Code Online (Sandbox Code Playgroud)

要么

 echo "Text text text"'!'
Run Code Online (Sandbox Code Playgroud)

要么

 echo -e "Text text text\x21"
Run Code Online (Sandbox Code Playgroud)


Per*_*o69 5

单引号:

echo 'Text Text Text!'
Run Code Online (Sandbox Code Playgroud)

为我做到了。