Thread: unix command for grouping....

  1. #1

    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
    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

    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?


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, 10: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, 07:37 AM