• 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
  • 相关阅读:
    MyBatis 配置文件 用户密码加密存储
    MyBatis 实例
    mybatis 入门搭建
    文件上传
    struts 结果类型
    Struts 拦截器
    log4j
    Struts Action 控制器
    Struts
    四、常用的Maven命令
  • 原文地址:https://www.cnblogs.com/sea-stream/p/10835227.html
Copyright © 2020-2023  润新知