许多问题,例如“如何键入双引号字符 (")?” 正在被问到,我们不想用相同的答案来扰乱我们的社区(输入时
\"
好像不包含在'
s 中,"
如果包含在'
s 中。)所以,问题就在这里。
您不能像普通字符那样在终端中输入特殊字符,例如此命令将失败:
echo Updates (11)
Run Code Online (Sandbox Code Playgroud)
那么,如何在终端中输入这些字符,就像它们是普通字符一样?
echo Updates (11)
Run Code Online (Sandbox Code Playgroud) 我最近在命令行上遇到了一些正则表达式的问题,发现为了匹配反斜杠,可以使用不同数量的字符。这个数字取决于用于正则表达式的引用(无、单引号、双引号)。请参阅以下 bash 会话以了解我的意思:
echo "#ab\\cd" > file
grep -E ab\cd file
grep -E ab\\cd file
grep -E ab\\\cd file
grep -E ab\\\\cd file
#ab\cd
grep -E ab\\\\\cd file
#ab\cd
grep -E ab\\\\\\cd file
#ab\cd
grep -E ab\\\\\\\cd file
#ab\cd
grep -E ab\\\\\\\\cd file
grep -E "ab\cd" file
grep -E "ab\\cd" file
grep -E "ab\\\cd" file
#ab\cd
grep -E "ab\\\\cd" file
#ab\cd
grep -E "ab\\\\\cd" file
#ab\cd
grep -E "ab\\\\\\cd" file
#ab\cd
grep -E "ab\\\\\\\cd" file
grep -E 'ab\cd' file
grep …
Run Code Online (Sandbox Code Playgroud)