RE: Print the first column of a file

From: Kenneth Goodwin (kgoodwin_at_datamarktech.com)
Date: 07/30/03

  • Next message: Aly Dharshi: "Re: Red Hat 10"
    To: <redhat-list@redhat.com>
    Date: Wed, 30 Jul 2003 15:14:11 -0400
    
    

    Depends on what the lines actually look like, check man/info
    pages but you could

    Try cut -f1 filename | sort | uniq

    you need to sort it first prior to UNIQ.

    > -----Original Message-----
    > From: redhat-list-admin@redhat.com
    > [mailto:redhat-list-admin@redhat.com]On Behalf Of Barry
    Johnson
    > Sent: Wednesday, July 30, 2003 2:31 PM
    > To: redhat-list@redhat.com
    > Subject: RE: Print the first column of a file
    >
    >
    > Awk is something that you could you
    >
    > More $filename|awk '{print $1}'|uniq will sort through
    the file and
    > print the first column
    >
    > -----Original Message-----
    > From: redhat-list-admin@redhat.com
    > [mailto:redhat-list-admin@redhat.com]
    > On Behalf Of Mark Neidorff
    > Sent: Wednesday, July 30, 2003 9:48 AM
    > To: redhat-list@redhat.com
    > Subject: Re: Print the first column of a file
    >
    >
    > On Tue, 29 Jul 2003, Reuben D. Budiardja wrote:
    >
    > >
    > > Hello,
    > > What command would I use to print just the first column
    of
    > a file? For
    > > example, the httpd (apache) access_log. The first
    column
    > contains the
    > IP
    > > address. How can I just output that, so that I can then
    pass it to
    > "uniq" to
    > > get the uniques IP addresses that requested a page from
    my server?
    > > Like:
    > >
    > > $> <command> | uniq
    > >
    > > Does this use something like 'sed' or 'gawk'? I need to
    > learn how to
    > > use those
    > > anyways :)
    > >
    > > Thanks for any help.
    > > RDB
    > >
    >
    > Take a look at the 'cut' command.
    >
    > Mark
    >
    >
    > --
    > redhat-list mailing list
    > unsubscribe
    mailto:redhat-list-request@redhat.com?subject=unsubscribe
    > https://www.redhat.com/mailman/listinfo/redhat-list
    >
    >
    > --
    > redhat-list mailing list
    > unsubscribe
    mailto:redhat-list-request@redhat.com?subject=unsubscribe
    > https://www.redhat.com/mailman/listinfo/redhat-list
    >

    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Aly Dharshi: "Re: Red Hat 10"