I am effectively looking to do the reverse of this question:
Turn list into single line with delimiter
where the best answer which worked for me was:
sed -e :a -e '$!N; s/\n/ | /; ta' mydoc > mydoc2
Any help much appreciated.
I am effectively looking to do the reverse of this question:
Turn list into single line with delimiter
where the best answer which worked for me was:
sed -e :a -e '$!N; s/\n/ | /; ta' mydoc > mydoc2
Any help much appreciated.
Just use the tr
command to change replace the <space>|<space>
sequence with a newline character
tr -s ' | ' '\n' < mydoc > mydoc2
tr -s '| ' '[\n*]'
) would translate any sequence of one or more SPC
, |
or LF
characters to one LF
(contrary to what the first paragraph says) so would address both cases.
– Stéphane Chazelas
May 29 '20 at 15:31
using awk :
awk 'BEGIN { RS="|"} { gsub(" ","");print >> "mydoc2" }' mydoc