gpt4 book ai didi

linux - 将每 n 行转置为一行

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:51:42 24 4
gpt4 key购买 nike

我想把一堆 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com