如何grep的美元符号($)?
% cat temp $$$ hello1 $$ hello2 hello3 ## hello4 hello5 $$$ % cat temp | grep "$$$" Illegal variable name. % cat temp | grep "\$\$\$" Variable name must contain alphanumeric characters. %  我希望grep为$$$ ,我期望的结果是 
 % cat temp | grep <what should go here?> $$$ hello1 hello5 $$$ % 
 为了区分,我将提示标记为% 。 
- 这里有什么问题?
- grepstring应该是什么?
 问题是shell在双引号string内展开variables名称。 所以对于"$$$"它试图从第一个$开始读取variables名。 
 另一方面,在单引号中,variables不会被扩展。 因此, '$$$' 将起作用 – 如果它不是因为$是表示行结尾的正则expression式中的特殊字符。 所以它需要被转义: '\$\$\$' 。 
 当您使用双引号"或没有使用双\: "\\\$\\\$\\\$" 
 cat t | grep \\\$\\\$\\\$ 
如果你使用单引号,你可以使用:
 cat t | grep '\$\$\$' 
 $ grep '\$\$\$' temp $$$ hello1 hello5 $$$ 
你的命令中有一个超级“猫”。
适用于我:
 user@host:~$ cat temp | grep '\$\$\$' $$$ hello1 hello5 $$$ user@host:~$ 
 怎么样^.*[$]{3}.*$