Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize column-column swap in linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how linux to achieve the exchange of ranks, has a certain reference value, interested friends can refer to, I hope you read this article after a great harvest, the following let Xiaobian take you to understand.

linux column interchange

row to column

Sample files are as follows

cat file.txta b cd e fg h i

1、cat file.txt |xargs -n1

2、xargs -n 1 < file.txt

3、tr " " "\n" < file.txt

4、sed 's/ /\n/g' file.txt

This command works fine on Linux but does not work on Mac because sed on Mac is BSD and Gnu on Linux, and you need sed -e 's/ /\'$'\n/g' file.txt on Mac

5、awk '{for(i=1;i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report