【awk】awk之RS、ORS与FS、OFS

2021-11-12  本文已影响0人  Bogon

awk next 将多行合并成一行显示

http://www.361way.com/awk-next-merge-lines/4923.html

awk之RS、ORS与FS、OFS:将文件每隔三行合并成一行

https://www.cnblogs.com/chenjiahe/p/6164673.html

sed/tr替换换行符

https://blog.csdn.net/u011417820/article/details/79791900

############@@@@@@@@#########################

$ ansible -i hosts all -m shell -a "lsblk | grep $device_name |   awk '{print \$1,\$4}'" | awk ' {print $1,$2;}' | tr '|' ' ' | awk '{if(NR%2!=0)ORS=" ";else ORS="\n"}1'

$ device_name = "centos-home"

$ ansible -i hosts all -m shell -a "lsblk | grep $device_name |  awk '{print \$1,\$4}'" | awk ' {print $1,$2;}' | tr '|' ' ' | awk '{if(NR%2!=0)ORS=" ";else ORS="\n"}1' | awk '{printf "%-20s %-20s %-20s \n",$1,$2,$3}'

上一篇 下一篇

猜你喜欢

热点阅读