Date: Mon, 15 Apr 2002 20:52:40 +0200 From: Erik Trulsson <ertr1013@student.uu.se> To: lcroker@megared.net.mx Cc: freebsd-questions@FreeBSD.ORG Subject: Re: GREP ! Message-ID: <20020415185239.GA8296@student.uu.se> In-Reply-To: <1018877866.25155.20.camel@matrix.corp.megared.net.mx> References: <1018877866.25155.20.camel@matrix.corp.megared.net.mx>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020415185239.GA8296>