From owner-freebsd-questions Mon Apr 15 11:52:55 2002 Delivered-To: freebsd-questions@freebsd.org Received: from maila.telia.com (maila.telia.com [194.22.194.231]) by hub.freebsd.org (Postfix) with ESMTP id EAD2337B41A for ; Mon, 15 Apr 2002 11:52:47 -0700 (PDT) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by maila.telia.com (8.11.6/8.11.6) with ESMTP id g3FIqkS03737 for ; Mon, 15 Apr 2002 20:52:46 +0200 (CEST) Received: from falcon.midgard.homeip.net (h53n2fls20o913.telia.com [212.181.163.53]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id UAA24946 for ; Mon, 15 Apr 2002 20:52:45 +0200 (CEST) Received: (qmail 8329 invoked by uid 1001); 15 Apr 2002 18:52:41 -0000 Date: Mon, 15 Apr 2002 20:52:40 +0200 From: Erik Trulsson To: lcroker@megared.net.mx Cc: freebsd-questions@FreeBSD.ORG Subject: Re: GREP ! Message-ID: <20020415185239.GA8296@student.uu.se> Mail-Followup-To: lcroker@megared.net.mx, freebsd-questions@FreeBSD.ORG References: <1018877866.25155.20.camel@matrix.corp.megared.net.mx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1018877866.25155.20.camel@matrix.corp.megared.net.mx> User-Agent: Mutt/1.3.28i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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.) -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message