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

 

相关文章

Centos系统之Shell编程基础知识
从Export理解Shell环境和变量生存期
linux shell数组变量、类型及规则
Centos编程Shell基本工作原理方案
Centos操作系统编程之Shell 问答录
rsync-linux备份脚本