-2

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.

Inian
  • 12,807
  • 4
    Please provide your input and expected output in this question. All information to answer a question should be contained in the question. – Quasímodo May 29 '20 at 15:23

2 Answers2

2

Just use the tr command to change replace the <space>|<space> sequence with a newline character

tr -s ' | ' '\n' < mydoc > mydoc2
Inian
  • 12,807
  • 1
    @Quasimodo, this answer (or at least its standard version 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
0

using awk :

awk 'BEGIN { RS="|"} { gsub(" ","");print >> "mydoc2" }' mydoc