zoukankan      html  css  js  c++  java
  • Linux-选取命令:cut grep

    cut : 将同一行里面的数据进行分解,最常使用在分析一些数据或文字数据的时候,以行为单位进行处理

    [----scripts]$ echo $PATH
    /usr/lib64/qt-3.3/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/go//bin
    [----scripts]$ echo $PATH|cut -d ':' -f 5
    /usr/local/bin
    [----scripts]$ echo $PATH|cut -d ':' -f 3,5
    /usr/sbin:/usr/local/bin
    
    [----scripts]$ echo $PATH|cut -c 3-5
    sr/

    格式:

    cut -d '分隔字符' -f fields 

    • -d 后面接分隔字符,与-f 一起使用
    • -f 是取出第几段的意思,根据-d分隔出来的信息,取第几段

    cut -c 字符范围

    • 示例一:cut -c 12-
    • 示例二:cut -c 12~20

    grep : 分析一行信息,当中如果有需要的信息,就取出来

    格式:

    grep [参数] [--color=auto] '查找字符串' 文件名

    • -v 反向输出,显示没有匹配字符串的那一行
    • -n 输出行号
    • -i 忽略大小写
    • --color=auto 关键字加上颜色显示
  • 相关阅读:
    知识积累
    来西安对吗
    python循环语句---------while、for
    postman接口功能测试
    Laravel环境搭建
    Vue
    搭建Vue.js环境
    Atom
    PHP
    thinkphp-无限分类下根据任意部门获取顶级部门ID
  • 原文地址:https://www.cnblogs.com/starstarstar/p/11189257.html
Copyright © 2011-2022 走看看