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

Re: Just a question



on Thu, Aug 30, 2001 at 11:09:07PM -0500, ktb (x.y.f@home.com) wrote:
> On Thu, Aug 30, 2001 at 08:45:29PM -0700, Vineet Kumar wrote:
> > 
> > * Brian Schramm (brian.schramm@ncmail.net) [010830 19:41]:
> > > Is there a way that I can take a passwd file and compare the full name data 
> > > in it to the email ldap server and give a a list of what it finds and what it 
> > > misses?  I am doing this manually but with the number of users that there are 
> > > involved it is going to be really time consuming.
> > 
> > I don't really know what I'm talking about, but this should probably
> > help you get started:
> > 
> > awk -F : '{print $5}' /etc/passwd | sed -e "s/^\([^,]*\).*$/\1/"
> > 
> > That will give you a list of just the full names. Pipe that into
> > something else that will look each one up in the directory service.
> > 
> > Not a complete answer, but it's a start...
> 
> 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

In the original pattern:

    sed -e "s/^\([^,]*\).*$/\1/"

We have:

  -e:	expression to evaluate.
  s:	create a substitution using the following pattern.
  /	start of expression
  ^	beginning of line (actually, beginning of fifth field
  \(	start a substitution
  [^,]* match zero or more instances of any character other than ','
  \)	end substitution
  .*$	match to end of line
  /	end of expression
  \1	replace with contents of first substitution (the \([^,]*\)
        pattern)
  /	end expression

sed is for people who think Perl's too easy to understand.

-- 
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: pgpEbxFQjXIZD.pgp
Description: PGP signature


Reply to: