linux 中实现两列数据的互换

1、awk实现

root@PC1:/home/test2# ls
test.txt
root@PC1:/home/test2# cat test.txt   ## 测试数据
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
17 18 19 20
root@PC1:/home/test2# awk '{temp = $1; $1 = $2; $2 = temp; print $0}' test.txt  ## 实现第一列数据和第二列数据的互换
02 01 03 04
06 05 07 08
10 09 11 12
14 13 15 16
18 17 19 20

 

posted @ 2021-12-27 10:19  小鲨鱼2018  阅读(2941)  评论(0)    收藏  举报