Skip site navigation (1)Skip section navigation (2)
Date:      15 Apr 2002 16:09:05 +0000
From:      Lu!s Croker <lcroker@matrix.corp.megared.net.mx>
To:        Erik Trulsson <ertr1013@student.uu.se>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: GREP !
Message-ID:  <1018886949.238.0.camel@matrix.corp.megared.net.mx>
In-Reply-To: <20020415185239.GA8296@student.uu.se>
References:  <1018877866.25155.20.camel@matrix.corp.megared.net.mx>  <20020415185239.GA8296@student.uu.se>

next in thread | previous in thread | raw e-mail | index | archive | help

    It works... Thanks a lot. 


On Mon, 2002-04-15 at 18:52, Erik Trulsson wrote:
> On Mon, Apr 15, 2002 at 01:37:43PM +0000, Lu!s Croker wrote:
> > 
> >     Hi,  I need to filter a specific line  of /etc/passwd, but grep can
> > not do it... for example, if I want to filter the line of "luis" user,
> > grep filter every lines that contain  luis word, (luis.croker,
> > luis-alberto, etc.). Man specifics -x parameter for exact matches... but
> > it doesnt work, if I use it,  no one line is filtered...  How can I
> > filter a specific line?, Any Idea or another method?
> 
> grep can do it, you just need to understand how to use it.
> If you just do a 'grep "luis" /etc/passwd' it will, correctly, output
> every line containing "luis".  If you use the -x flag it will only
> print those lines exactly matching the regular expression you look for
> instead of those lines that contain it together with possibly something
> else.
> 
> So how do you do it?
> You construct a regular expression matching what you want to look for.
> In your case you are looking for the line in /etc/passwd containing
> data for teh user with username "luis"
> Looking in /etc/passwd the format is that each line starts with the
> username followed by a ':'.
> So lets tell grep to look for the lines you are after:
> 
> grep "^luis:" /etc/passwd
> 
> (The "^" matches the beginning of a line.)
> 
> 
> 
> 
> 
> -- 
> <Insert your favourite quote here.>
> Erik Trulsson
> ertr1013@student.uu.se
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1018886949.238.0.camel>