From owner-freebsd-questions@FreeBSD.ORG Wed Oct 8 07:12:11 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B4AD1065697 for ; Wed, 8 Oct 2008 07:12:11 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from mailout.zetnet.co.uk (mailout.zetnet.co.uk [194.247.47.231]) by mx1.freebsd.org (Postfix) with ESMTP id C94348FC0A for ; Wed, 8 Oct 2008 07:12:10 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from irwell.zetnet.co.uk ([194.247.47.48] helo=zetnet.co.uk) by mailout.zetnet.co.uk with esmtp (Exim 4.63) (envelope-from ) id 1KnTDH-0006j3-J5; Wed, 08 Oct 2008 08:12:03 +0100 Received: from melon.esperance-linux.co.uk (54-144.adsl.zetnet.co.uk [194.247.54.144]) by zetnet.co.uk (8.14.1/8.14.1/Debian-9) with ESMTP id m987C1xW003126; Wed, 8 Oct 2008 08:12:02 +0100 Received: by melon.esperance-linux.co.uk (Postfix, from userid 1001) id A515BFCA4AD; Wed, 8 Oct 2008 08:11:56 +0100 (BST) Date: Wed, 8 Oct 2008 08:11:56 +0100 From: Frank Shute To: Kalpin Erlangga Silaen Message-ID: <20081008071156.GA94922@melon.esperance-linux.co.uk> Mail-Followup-To: Kalpin Erlangga Silaen , freebsd-questions@freebsd.org References: <48EC410C.2030707@muliahost.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48EC410C.2030707@muliahost.com> User-Agent: Mutt/1.4.2.3i X-Face: *}~{PHnDTzvXPe'wl_-f%!@+r5; VLhb':*DsX%wEOPg\fDrXWQJf|2\,92"DdS%63t*BHDyQ|OWo@Gfjcd72eaN!4%NE{0]p)ihQ1MyFNtWL X-Operating-System: FreeBSD 6.3-RELEASE-p2 i386 X-Organisation: 'http://www.shute.org.uk/' X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (zetnet.co.uk [194.247.46.1]); Wed, 08 Oct 2008 08:12:03 +0100 (BST) Cc: freebsd-questions@freebsd.org Subject: Re: bash script on FreeBSD X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Frank Shute List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2008 07:12:11 -0000 On Wed, Oct 08, 2008 at 12:11:40PM +0700, Kalpin Erlangga Silaen wrote: > > Dear all, > > I am going to extract field username and UID from /etc/passwd and passed > into some scripts. Let say I got line > > admin 100 > admin2 200 > admin3 300 > admin4 400 > > and then I want to echoing into screen: > > admin has uid 100 > admin2 has uid 200 > admin3 has uid 300 > admin4 has uid 400 > > How do I make this with bash script? > > Thank you > > > Kalpin Erlangga Silaen $ sed -e 's/\(admin[0-9]*\)\ \([0-9]*\)/\1 has uid \2/g' /etc/passwd Regards, -- Frank Contact info: http://www.shute.org.uk/misc/contact.html