unix command for grouping....

This is a discussion on unix command for grouping.... within the Linux Programming forums, part of the Platform Specific Boards category; I have this type of output which has been previously sorted for example, A 1 A 2 A 3 A ...

  1. #1
    kiss2rvp
    Guest

    Unhappy unix command for grouping....

    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

  2. #2
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    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.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  3. #3
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    Hi!

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

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

    is this what you want?

    alex

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 10:54 AM
  2. Setting up a Unix box
    By @nthony in forum Tech Board
    Replies: 6
    Last Post: 07-22-2007, 11:22 PM
  3. UNIX (Linux, BSD, etc) Programming :: UNIX
    By kuphryn in forum Linux Programming
    Replies: 6
    Last Post: 04-01-2004, 08:44 PM
  4. Unix Sockets
    By prvindia in forum Linux Programming
    Replies: 5
    Last Post: 03-11-2003, 09:16 AM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21