
awkで最後の列からn個前の列を抽出する場合は、以下のようにすればよい。
bash
awk '{print $(NF-n)}'
shell[root@BS-PUB-CENT7-01 ~]# cat /tmp/test.txt aaa="1" bbb="2" ccc="3" ddd="4" aaa="11" bbb="21" ccc="31" ddd="41" aaa="12" bbb="22" ccc="32" bbb="3rqt" ddd="42" aaa="13" bbb="23" ccc="33" ddd="43" aaa="14" bbb="24" ccc="34" ddd="44" aaa="15" bbb="25" ccc="35" ddd="45" aaa="16" bbb="26" ccc="36" ddd="46" aaa="17" bbb="27" ccc="37" ddd="47" aaa="18" bbb="28" ccc="38" ddd="48" [root@BS-PUB-CENT7-01 ~]# awk '{print $(NF-1)}' /tmp/test.txt ccc="3" ccc="31" bbb="3rqt" ccc="33" ccc="34" ccc="35" ccc="36" ccc="37" ccc="38" [root@BS-PUB-CENT7-01 ~]# awk '{print $(NF-2)}' /tmp/test.txt bbb="2" bbb="21" ccc="32" bbb="23" bbb="24" bbb="25" bbb="26" bbb="27" bbb="28"