I'd like to replace all the newlines after a line containing a given pattern with a tab.
Input file:
$ cat File1
NAME1
N1_info
NAME2
N2_info
I'm creating some flags at the ends of the future "tab"s:
sed '/^NAME/s/$/\*/g; /^NAME/!{s/^/+/g}' File1.txt > File2.txt
$ cat File2
NAME1*
+N1_info
NAME2*
+N2_info
Then I'm removing the characters between the "flags" in order to obtain the wished output. I tried two sed patterns (but none of them change my 'File2'):
head File2 | sed -e 's/\(\*\).*\(+\)/\1\t\2/g'
head File2 | sed -n '/\*/,/+/p'
This is the what the output should look like:
$ cat File3
NAME1 N1_info
NAME2 N2_info
sed $'/^NAME/{N;s/\\n/\t/;}'