如何grep文件中不区分大小写的字符串? [英] How to grep for case insensitive string in a file?
问题描述
我有一个文件 file1
以成功...
或成功...
I have a file file1
which ends with
Success...
OR
success...
我想以不区分大小写的方式对 success
这个词 grep
进行grep
.
I want to grep
for the word success
in a way which is not case sensitive way.
我已经编写了以下命令,但它区分大小写
I have written the following command but it is case sensitive
cat file1 |grep "成功..."
我如何更改它以便 returns 0
与 Success...
或成功...
How can i change it so that it returns 0
with both Success...
OR
success...
推荐答案
您可以使用 -i
标志使您的模式不区分大小写:
You can use the -i
flag which makes your pattern case insensitive:
grep -iF "success..." file1
另外,也不需要cat
.grep
使用语法 grep
-F
标志来搜索固定字符串以避免转义省略号.
Also, there is no need for cat
. grep
takes a file with the syntax grep <pattern> <file>
. I also used the -F
flag to search for a fixed string to avoid escaping the ellipsis.
这篇关于如何grep文件中不区分大小写的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!