linux系统中如何把连续的两列数据转换成一列数据
2021/11/3 7:11:25
本文主要是介绍linux系统中如何把连续的两列数据转换成一列数据,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1、测试数据
root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt 1 2 3 4 5 6 7 8 e a w d g e l i d g e g j j m n
2、将连续的两列数据转换成一列数据
root@PC1:/home/test2# cat a.txt 1 2 3 4 5 6 7 8 e a w d g e l i d g e g j j m n root@PC1:/home/test2# awk '{for(i = 1; i <= NF; i = i + 2) {printf("%s ", $i)}{printf("\n")}}' a.txt > top.txt root@PC1:/home/test2# cat top.txt 1 3 5 7 e w g l d e j m root@PC1:/home/test2# awk '{for(i = 2; i <= NF; i = i + 2) {printf("%s ", $i)}{printf("\n")}}' a.txt > bottom.txt root@PC1:/home/test2# cat bottom.txt 2 4 6 8 a d e i g g j n root@PC1:/home/test2# cat top.txt bottom.txt > result.txt root@PC1:/home/test2# cat result.txt 1 3 5 7 e w g l d e j m 2 4 6 8 a d e i g g j n
这篇关于linux系统中如何把连续的两列数据转换成一列数据的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-11Linux部署Scrapy学习:入门级指南
- 2024-09-11Linux部署Scrapy:入门级指南
- 2024-08-21【Linux】分区向左扩容的方法
- 2024-08-21【Linux】gnome桌面环境切换KDE Plasma
- 2024-08-19如何安装 VMware Tools (macOS, Linux, Windows)
- 2024-08-15Linux部署Scrapy教程:入门级指南
- 2024-07-29linux命令行下好用的性能监控工具atop
- 2024-07-04Linux系统上离线升级SSH服务的具体操作步骤-icode9专业技术文章分享
- 2024-06-0600-macOS和Linux安装和管理多个Python版本
- 2024-03-30[译]漫画SELinux概念