Grep:如何 grep 查找包含冒号的字符串
我想 grep 查找以冒号 :
开头的字符串,其中包含 0 个或多个字符,然后以字符串 mystring
结尾。
我尝试了这个: grep -rI ':*mystring' .
但这不起作用。
通过搜索,我认为这不起作用的原因是因为它匹配“0个或多个冒号字符 :
的实例,后跟 mystring
。(查看这个问题的答案)
这对我来说没有多大意义,因此我的 。
编辑: 无 链接问题中的答案解决了这个问题,没有提到匹配冒号字符,并且尝试调整答案也不起作用。
I want to grep for a string which begins with a colon :
, the contains 0 or more characters of anything, and then ends with the string mystring
.
I tried this: grep -rI ':*mystring' .
but this did not work.
From searching, I believe the reason this does not work is because it is matching "0 or more instances of the colon character :
followed by mystring
. (See an answer on this question)
That doesn't make much sense to me, hence my question.
Edit: None of the answers in the linked question solve this problem. There is no mention of matching a colon character, and trying to adapt the answers does not work either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
详细信息:
^
- 字符串开头:
- 冒号.*
- 任何零个或多个字符mystring
- 一个字符串。You can use
Details:
^
- start of string:
- a colon.*
- any zero or more charsmystring
- a string.