你如何grep一个包含斜杠的字符串? [英] How do you grep for a string containing a slash?
本文介绍了你如何grep一个包含斜杠的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何grep一个包含正斜杠的字符串,如 ./。
?
How should I grep for a string containing a forward slash like ./.
?
推荐答案
你只需要用反斜杠来避开这些句点。因此,如果我的文件 foo.txt
包含以下内容:
You'll just need to escape the periods with a backslash. So if I have a file foo.txt
with contents:
./.
foo
bar
./.
我可以运行 grep \。/ \。 test.txt
,它应该只显示两个 ./。
行。
I can run grep \./\. test.txt
, which should just print the two ./.
lines.
这篇关于你如何grep一个包含斜杠的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文