my input:
ads bdsd cds dds
ac cv ss ds
dsd
output I expect:
ads
bdsd
cds
dds
ac
cv
ss
ds
dsd
command I used:
cat file1.txt | perl -p -i -e 's/\n(. )/$1/'
but it does not work
CodePudding user response:
Try this:
cat file1.txt | tr -s " " "\n"
Basically, it replaces spaces with newlines and removes empty lines.
CodePudding user response:
Try rq
(https://github.com/fuyuncat/rquery/releases), use 'coltorow' convert columns to rows.
[ rquery]$ ./rq -q "p d/ /r | s coltorow(foreach(1,%,$)) | f trim(@raw)!=''" samples/mulcoltorow.txt
ads
bdsd
cds
dds
ac
cv
ss
ds
dsd