[[email protected] aa]# cat oldboy.txt
I am oldboy myqq is 49000448
[[email protected] aa]# cat oldboy.txt |cut -d " " -f3,6
oldboy 49000448
[[email protected] aa]# awk ‘{print $3,$6}‘ oldboy.txt
oldboy 49000448
多个分隔符
[[email protected] aa]# cat oldboy.txt
I am oldboy,myqq is 49000448
[[email protected] aa]# awk -F ‘[ ,]‘ ‘{print $3" "$6}‘ oldboy.txt
oldboy 49000448
[[email protected] aa]# cat /etc/services |wc -l
10774
[[email protected] aa]# cat -n /etc/services |tail -1 查看结果的最后一行
10774 iqobject 48619/udp # iqobject
[[email protected] aa]# awk ‘{print NR}‘ /etc/services |tail -1
10774
[[email protected] aa]# grep -n $ /etc/services |tail -1
10774:iqobject 48619/udp # iqobject
时间: 2024-10-11 12:02:52