zoukankan      html  css  js  c++  java
  • linux常用命令 cut字符截取命令

    cut 字符截取

    cut [选项] 文件名

    选项
    -f 列号: 提取第几列
    -d 分割符:按照指定的分隔符分割列
    

    默认使用制表符("tab")进行分割

    ssgao:Downloads aouo$ cut -f 2 ssgao.txt  获取第列
    ssgao
    ssgao:Downloads aouo$ cut -f 2,4 ssgao.txt 获取第4列
    ssgao   37
    

    使用自定义的分割符

    ssgao:Downloads aouo$ cat ssgao.txt 
    name,ssgao,age,37
    ssgao:Downloads aouo$ cut -f 1 -d "," ssgao.txt  #使用","进行分割,并获取第一列,-f和-d的前后顺序可以互换
    name
    ssgao:Downloads aouo$ 
    

    cut命令的缺点

    很复杂的分割,比如df -h 输出的的时候有多个空格
    ssgao:Downloads aouo$ df -h
    Filesystem      Size   Used  Avail Capacity iused      ifree %iused  Mounted on
    /dev/disk1     233Gi   80Gi  153Gi    35% 1054436 4293912843    0%   /
    devfs          182Ki  182Ki    0Bi   100%     631          0  100%   /dev
    map -hosts       0Bi    0Bi    0Bi   100%       0          0  100%   /net
    map auto_home    0Bi    0Bi    0Bi   100%       0          0  100%   /home
    
  • 相关阅读:
    C# 根据实体将DataTable拆分成表头表体
    html KeyDown 当键盘按下时 获取所按键的Code
    Linq ExecuteQuery,ExecuteCommand
    Linq To Object
    Var To DataTable
    Linq to SQL 基础篇
    反射生成SQL语句
    Ajax跨域请求ashx文件与Webservice文件
    Ajax调用WebService
    DataTableToJson
  • 原文地址:https://www.cnblogs.com/ssgao/p/8881887.html
Copyright © 2011-2022 走看看