Linux grep 中间带有通配符的文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5906228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:57:48  来源:igfitidea点击:

grep for text with wild card in between

linuxsedawkgreptail

提问by beatbreaker

I would like to grep something like ==> *.sh <==. But it doesn't work, I can grep everything up to .sh <==but not get the wild card to work.

我想 grep 类似的东西==> *.sh <==。但它不起作用,我可以grep一切,.sh <==但不能让通配符起作用。

What's the trick here?

这里有什么诀窍?

采纳答案by sayap

You need to grep for something like "==> .*\.sh <=="

你需要为类似的东西grep "==> .*\.sh <=="

The .*part matches any character for any length, the \.part matches a dot.

.*部分匹配任何长度的任何字符,该\.部分匹配一个点。