Linux搜索字符串在带有空间的文件中
我试图弄清楚如何在Linux中搜索字符串,希望有人可以帮助我。
grep "Test\|Account" test.txt
如果我只想搜索一个单词,则上述命令有效。 但是,当我尝试搜索“创建测试'帐户'”时,不确定如何使用GREP,因为我是Linux中的新手。
Im trying to figure out how to search a string in Linux i hope someone can help me out.
grep "Test\|Account" test.txt
The above command works if i only want to search for one word.
But when i try to search "Create Test 'account'" not sure how to use grep since im a newbie in Linux.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用GNU
GREP
,您可以在此处使用,因为它们在评估它们的双引号字符串中被使用,因此将其逃脱。
|
REGEX交替操作员被逃脱了,因为它被认为是字面的管子char。详细信息:
创建测试'帐户'
- 字面文本\ |
- 或创建test test`earcepor`
a字面文字With a GNU
grep
, you can useHere, the backticks are escaped since they are used inside a double quoted string where they are evaluated. The
|
regex alternation operator is escaped because it is considered a literal pipe char otherwise.Details:
Create Test 'account'
- a literal text\|
- orCreate Test `account`
- a literal text