I'd like to change \n by | between 2 patterns (patterns excluded) with sed.
I have a file with an adress sequence several time :
Adress:
1540 Broadway
New York
NY 10036
United-states
###
I would like to get that :
Adress:1540 Broadway|New York|NY 10036|United-states
###
I use the following line code :
sed -i "/^Adress:/!b;:a;/###/bb;$!{N;ba};:b;s/\n/\|/g;tb" file.txt
...but it includes the two patterns and I get this wrong result :
Adress:|1540 Broadway|New York|NY 10036|United-states|###
How to change it to exclude patterns from the substitute?
I tried this but it doesn't work :
How can I handle the fact that the last record is not terminated with a "###" line ?
– Syl33 Jun 27 '17 at 12:22