I am trying to bring bunch of n lines into a single line,not sure how to do it. Any help is appreciated.
bunch of 11 words then a blank line and then again bunch of ll words and then blank like...so on.
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
..
..
Through 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
Treating blocks of text separated by blank lines as a single record is known as paragraph mode in awk:
$ awk -v RS= '{$1=$1}1' file
hi hello how are you i am fine how are you
hi how is she doing i have not herd from her
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With