linux awk获取倒数某一列
创始人
2025-05-28 02:10:45

结果可以从man手册找到

  • -F参数
    -F fs
    –field-separator fs
    Use fs for the input field separator (the value of the FS predefined variable).

    -F参数指定用于分割的字符或者是字符串。

  • Fields
    As each input record is read, gawk splits the record into fields, using the value of the FS variable as the field separator.If FS is a single character, fields are separated by that character. If FS is the null string, then each individual character becomes a separate field.

  • NF(代表的是被分割后的字段总数)
    The variable NF is set to the total number of fields in the input record.

以下字段为例:
| `- 17:0:0:0 sdl 8:176 active ready running

  • 获取以空格为分隔符,倒数第一列数据
echo '| `- 17:0:0:0  sdl  8:176  active ready running' | awk -F " " '{print $NF}'

结果为:running

  • 获取以空格为分隔符,倒数第二列数据
echo '| `- 17:0:0:0  sdl  8:176  active ready running' | awk -F " " '{print $(NF-1)}'

结果为:ready

相关内容

热门资讯

自己创建房间的斗牛“新道游房卡... 自己创建房间的斗牛“新道游房卡购买入口”牛牛房卡专卖店【产品名称】 微信链接金花牛牛房卡(商家专属渠...
乐酷房卡怎么买,乐酷房卡“新道... 乐酷房卡怎么买,乐酷房卡“新道游新世界房卡”牛牛房卡批发价格在金花游戏中,微信炸金花开房间的关键在于...
新大圣房卡一千张多少“皇豪互娱... 要合法地购买房卡,直接和安全的渠道是通过微信和游戏商店。以下是具体的购买方法:新大圣房卡一千张多少“...
皇豪互娱怎么建房间“乐酷房卡怎... 皇豪互娱怎么建房间“乐酷房卡怎么买”新老夫子房卡代理,咨询房/卡添加微信:【1582660429】许...
新道游各种卡“新518房卡怎么... 新道游各种卡“新518房卡怎么充值”金花链接房卡充值【产品名称】 微信链接金花牛牛房卡(商家专属渠道...