unix command for grouping.... [Archive] - C Board

PDA

View Full Version : unix command for grouping....


kiss2rvp
05-23-2002, 06:58 AM
I have this type of output which has been previously sorted for example,

A 1
A 2
A 3
A 1
B 2
B 3
C 2

But now i want to remove the A, B, & C using cut but separate the groups so i will still be able to identify the numbers that belong to each letter for example a line to separate each group....

is there some command to do this or some method???

thanks in advance

Lynux-Penguin
05-25-2002, 12:10 AM
scripting
not command line... if so then it would look UGLY like
grep "pattern" | cut "patter"; cp ...;... ... | ...;...
really long...
Perl would be the best way to go about it.

alex
05-29-2002, 09:49 AM
Hi!

We'll have to advertise the awk filter! :cool:
(I just replied to similar question)

awk '{if(NR>1 && x!=$1) print ""; print $2; x=$1}' groupfile

is this what you want?

alex