How to print columns one after the other in bash?

后端 未结 7 1379
感情败类
感情败类 2021-01-14 19:06

Is there any better methods to print two or more columns into one column, for example

input.file

AAA    111
BBB    222
CCC    333

o

7条回答
  •  失恋的感觉
    2021-01-14 19:25

    This will work for an arbitrary number fo space separated colums

    awk  '{for (A=1;A<=NF;A++) printf("%s\n",$A);}' input.file | sort -u > output.file
    

    If space is not the separateor ... let's suppose ":" is the separator

    awk -F: '{for (A=1;A<=NF;A++) printf("%s\n",$A);}' input.file | sort -u > output.file
    

提交回复
热议问题