This question came up in another thread so I wanted to see if
it could be done purely with sed[\b] instead of awk or shell.
This is my output as it stands now
Any ideas how to branch or do an if/else test to get it to print as expected?
it could be done purely with sed[\b] instead of awk or shell.
The output should be# cat text
A 0
A 1
B 2
C 3
C 4
C 5
D 6
D 7
E 8
E 9
I've come close but am missing how to evaluate the first column of the next line with the previousA 0,1
B 2
C 3,4,5
D 6,7
E 8,9
Code:
sed '/^$/!{
h
s/\(.*\) \(.*\)\n/\1/
N
s/\(.*\) \(.*\)\n/\1 \2,/
s/,[A-Z]/,/
s/, /,/
}' text
This is my output as it stands now
# ./s
A 0,1
B 2,3
C 4,5
D 6,7
E 8,9
Any ideas how to branch or do an if/else test to get it to print as expected?