[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Just a question



on Fri, Aug 31, 2001 at 11:53:57AM -0400, Brian Stults (bstults@soc.ufl.edu) wrote:
> >>BTW what does [ sed -e "s/^\([^,]*\).*$/\1/" ] accomplish?  I'm just
> >>grooving on one liners lately and am curious.  It seems like -
> >>awk -F : '{print $5}' /etc/passwd is all you need to spit out the full
> >>names.
> >>
> >Not quite the same thing:
> >
> >    $ awk -F : '/karsten/ {print $5}' /etc/passwd
> >    Karsten M. Self,,,
> >
> >    
> >    $ awk -F : '{print $5}' /etc/passwd | sed -e "s/^\([^,]*\).*$/\1/"
> >    Karsten M. Self
> >
> 
> 
> Or, if you only know awk...
> 
> awk -F : '/Brian/ {print $5}' /etc/passwd | awk -F , '{print $1}'

...or:

    awk -F : '/karsten/ {print substr($5,1,index($5,",")-1)}' /etc/passwd

...in one process.

-- 
Karsten M. Self <kmself@ix.netcom.com>          http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?             There is no K5 cabal
  http://gestalt-system.sourceforge.net/               http://www.kuro5hin.org
   Free Dmitry! Boycott Adobe! Repeal the DMCA!    http://www.freesklyarov.org
Geek for Hire                        http://kmself.home.netcom.com/resume.html

Attachment: pgpTQAZfJid9J.pgp
Description: PGP signature


Reply to: