awk 用法

[root@VM-0-6-centos test]# ifconfig| awk '/eth0/{print $2}'  #找到eth0那一行
flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
awk -F ',' '{print $NF}' ./txt  #取文件的倒数第一列的值
awk -F ',' '{print $(NF-1)}' ./txt #取文件的倒数第2列的值
awk -F ',' '{print $(NF-2)}' ./txt #取文件的倒数第3列的值

awk -F ',' '{print $NF=-2}' ./txt  #取文件中列的值为-2的 

cat test| awk 'NR==4' #(获取test文件的第4行)

参考 https://www.cnblogs.com/emanlee/p/3327576.html

相关文章:

  • 2021-09-11
  • 2021-09-30
  • 2021-09-16
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2021-10-31
  • 2021-07-30
  • 2021-12-02
相关资源
相似解决方案