How to print last two columns using awk

后端 未结 6 1295
甜味超标
甜味超标 2021-01-29 19:16

All I want is the last two columns printed.

6条回答
  •  北海茫月
    2021-01-29 19:46

    try with this

    $ cat /tmp/topfs.txt
    /dev/sda2      xfs        32G   10G   22G  32% /
    
    awk print last column
    $ cat /tmp/topfs.txt | awk '{print $NF}'
    
    awk print before last column
    $ cat /tmp/topfs.txt | awk '{print $(NF-1)}'
    32%
    
    awk - print last two columns
    $ cat /tmp/topfs.txt | awk '{print $(NF-1), $NF}'
    32% /
    

提交回复
热议问题