我想把一堆 n 行合并成一行,不知道该怎么做。任何帮助表示赞赏。
一堆 11 个单词,然后是一个空行,然后是一堆 ll 个单词,然后是空白,就像...等等。
示例:
cat filename
hi
hello
how
are
you
i
am
fine
how
are
you
hi
how
is
she
doing
i
have
not
herd
from
her
..
..
期望的输出:
cat newFile
hi hello how are you i am fine how are you
hi how is she doing i have not heard from her
..
..
最佳答案
通过 awk。
$ awk -v RS= '{gsub(/\n/, " ")}1' file
hi hello how are you i am fine how are you
hi how is she doing i have not herd from her
关于linux - 将每 n 行转置为一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29841404/