grep 不区分大小写_使用不区分大小写的Grep

grep 不区分大小写

grep 不区分大小写

grep is very useful too to  match and find phrases, words and characters in test. One of the most used situation is using grep case sensitive or case insensitive. In this tutorial we will examine different examples. We have all ready examined grep in the following tutorial.

grep在测试中匹配和查找短语,单词和字符时也非常有用。 最常用的情况之一是使用grep区分大小写或不区分大小写。 在本教程中,我们将研究不同的示例。 在下面的教程中,我们已经准备好检查grep

Linux grep Command Tutorial with Examples

Linux grep命令教程和示例

区分大小写(Case Sensitive)

We will start with the default behavior of the grep command which is case sensitive. In this example we will search for ismail in /etc/passwd .

我们将从区分大小写的grep命令的默认行为开始。 在此示例中,我们将在/etc/passwd搜索ismail

$ grep "ismail"  /etc/passwd
Case Sensitive
Case Sensitive
区分大小写

不区分大小写(Case Insensitive)

Now we will search for ISMAIL in a case insensitive manner. We expect to match both ismail and ISMAIL in /etc/passwd file. We will use -i option in order to specify case insensitivity.

现在,我们将以不区分大小写的方式搜索ISMAIL 。 我们希望在/etc/passwd文件中同时匹配ismailISMAIL 。 我们将使用-i选项以指定不区分大小写。

$ grep -i "ISMAIL" /etc/passwd
Case Insensitive
Case Insensitive
不区分大小写

不区分大小写和递归(Case Insensitive and Recursive)

In some cases we may need to search case insensitive and recursive manner. We will use -r option in order to make our case insensitive searchs recursively.  In this case we will search for ISMAIL case insensitive in /etc directory.

在某些情况下,我们可能需要搜索不区分大小写和递归的方式。 我们将使用-r选项以递归地进行不区分大小写的搜索。 在这种情况下,我们将在/etc目录中搜索不区分大小写的ISMAIL

$ grep -r -i "ISMAIL" /etc
Case Insensitive and Recursive
Case Insensitive and Recursive
不区分大小写和递归
LEARN MORE  Linux Bash Pipe Command Usage with Examples For Redirection
了解更多Linux Bash Pipe命令用法以及重定向示例

翻译自: https://www.poftut.com/using-grep-case-insensitive/

grep 不区分大小写

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值