zoukankan      html  css  js  c++  java
  • shell grep命令

    grep选项与参数:
    -a:将binary档案以text档案的方式搜寻数据
    -c:计算找到’搜寻字符串’的次数
    -i:忽略大小写
    -n:顺便输出行号
    -v:反向选择,亦即显示出没有’搜寻字符串’内容的那一行
    --color=auto:可以将找到的关键字部分加上颜色显示。color有三种参数(auto,always,never)
    如果加上--color=never可以去掉颜色
    [zhang@localhost ~]$ cat 1.txt 
    hello world
    abcdefg hijklmn
    opqrst uvwxyz
    abc
    hello
    world
    HEllo1
    hello2
    world3
    [zhang@localhost ~]$ cat 1.txt | grep hello
    hello world
    hello
    hello2
    搜索到的hello字段,默认红色,如果加上--color=never可以去掉颜色。
    添加-n参数,可以输出行号。
    [zhang@localhost ~]$ cat 1.txt | grep hello -n
    1:hello world
    5:hello
    21:hello2
    添加-i参数,忽略大小写。
    [zhang@localhost ~]$ cat 1.txt | grep hello -i
    hello world
    hello
    HEllo1
    hello2
    |连续使用
    [zhang@localhost ~]$ cat 1.txt | grep o | grep w
    hello world
    opqrst uvwxyz
    world
    world3
  • 相关阅读:
    细说Cookie(转)
    Custom Exception in ASP.NET Web API 2 with Custom HttpResponse Message
    内核中的定时器
    ibus拼音安装_ubuntu10.04
    linux模块
    zebra/quagga线程分析
    vim常用配置
    rar安装和使用
    zebra/quagga
    netsnmp编译动态库
  • 原文地址:https://www.cnblogs.com/sea-stream/p/10835227.html
Copyright © 2011-2022 走看看