Using bash to sort data horizontally

后端 未结 3 2119
执念已碎
执念已碎 2020-11-27 22:21

I have a file full of data in columns

sarah mark john
10    20   5
x     y    z 

I want to sort the data so the columns stay intact but the

3条回答
  •  独厮守ぢ
    2020-11-27 23:02

    Good one-liner gets the job done:

    perl -ane '$,=" "; print sort @F; print "\n";' file

    I found it here: http://www.unix.com/unix-for-advanced-and-expert-users/36039-horizontal-sorting-lines-file-sed-implementation.html

提交回复
热议问题