My input is in TSV format:
C1
r1
r2
r3
C2
r1
r3
Desired output is:
C1 r1
r2
r3
C2 r1
r3
So, basically what I want is printing value of column 1 in next line, is it possible using Linux command?
My input is in TSV format:
C1
r1
r2
r3
C2
r1
r3
Desired output is:
C1 r1
r2
r3
C2 r1
r3
So, basically what I want is printing value of column 1 in next line, is it possible using Linux command?
With GNU sed:
$ sed -i.bak '/^[^[:blank:]]/{N;s/\n[[:blank:]]\+//;}' file
C1r1
r2
r3
C2r1
r3
Possible solution is with awk
:
awk '$1 ~ /C/ { p = 1; save = $1; } $1 !~ /C/ { if (p) { x = save $1; print x; p = 0; } else { print $0; } }' input
Result:
C1r1
r2
r3
C2r1
r3