NAME READY STATUS RESTARTS AGE
grepme 1/1 Running 0 20h
grepmetoo 1/1 Running 0 19h
結果:
grepme
grepmetoo
「NAME」の下のすべてのアイテムを収集し、他のすべてのアイテムを削除するにはどうすればよいですか?
ベストアンサー1
使用
command | cut -d' ' -f1 | tail -n+2
# or if delimiter is tab
command | cut -f1 | tail -n+2
# or
command | awk 'NR>1{print $1}'
# or
command | csvcut -d' ' -c NAME | tail -n+2
# or if delimiter is tab
command | csvcut -t -c NAME | tail -n+2
前述したように、grep
次のものを使用することもできます。
command | grep -o '^[^[:blank:]]*' | tail -n+2
しかし、読みにくいので、上記の内容を好む。
このcut
ソリューションは最高のパフォーマンスを提供しますが、csvcut
断然最悪です。