I have a file in the following format. Groups of data merge together and the group number is indicated above each group.
1
adrf
dfgr
dfg
2
dfgr
dfgr
3
dfef
dfr
fd
4
fgrt
fgr
fgg
5
fgrt
fgr
fgr
.
.
.
.
50
dfgr
dfd
fdd
fdf
dfdg
I wanted to add another column (separated by tab) such that the file looks like:
adrf 1
dfgr 1
dfg 1
dfgr 2
dfgr 2
dfef 3
dfr 3
fd 3
fgrt 4
fgr 4
fgg 4
fgrt 5
fgr 5
fgr 5
.
.
.
.
50
dfgr 50
dfd 50
fdd 50
fdf 50
dfdg 50
Basically add a column that contains the number of each group and delete the group heading and merge.
Is there an efficient way using shell scripting to do it. I have 1000's of such small groups to manipulate.
Please let me know.