Gossamer Forum
Home : General : Chit Chat :

awk question

Quote Reply
awk question
Hi All, I just started taking Unix and need help with my assignment.

/home% cat file1
1file08
2file08
1file03
1file05
2file05
1file09
2file09

I need to group all lines that start with 1 and the same thing with lines that start with 2. My output should be:

GROUP1
(1,1file08)
(2,1file03)
(3,1file05)
(4,1file09)

GROUP2
(1,2file08)
(3,2file05)
(4,2file09)

I can use grep to group the files but the problem is the "number" before it. Note on GROUP2 does not have level 2 because there is not 2file03.

Thanks for any input you may have.

~Narsman