From owner-freebsd-questions Thu May 17 7:17: 2 2001 Delivered-To: freebsd-questions@freebsd.org Received: from dsl-64-193-218-89.telocity.com (dsl-64-193-218-89.telocity.com [64.193.218.89]) by hub.freebsd.org (Postfix) with SMTP id 40DAE37B422 for ; Thu, 17 May 2001 07:16:59 -0700 (PDT) (envelope-from lucas@slb.to) Received: (qmail 26761 invoked by uid 1000); 17 May 2001 14:17:17 -0000 Date: Thu, 17 May 2001 09:17:17 -0500 From: Lucas Bergman To: Don O'Neil Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Help w/ Awk Message-ID: <20010517091717.A634@billygoat.slb.to> Reply-To: lucas@slb.to References: <20010516115758.L26110@welearn.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from don@whtech.com on Tue, May 15, 2001 at 07:08:10PM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > That's a simpler way of doing it, but doesn't accomplish what I'm trying to > do. I'm trying to be able to loop through each user and get it's UID/GID and > do stuff... > > My problem wasn't with my AWK statement, but with my for/next loop. > > For whatever reason (still unknown), the for Line in Password was failing, > and was returning multiple lines, like there were EOL's embedded in the > lines. You're right. The shell assumes the argument to 'for' is a list, a string that it breaks into list elements at _any_ whitespace, not just newlines. So, if your /etc/passwd lines had whitespace in them (and they frequently do in the GECOS field), they would get broken in the middle. A previous response already pointed out a solution, passing the file to awk, which iterates over whole lines by default. You can use the shell's 'read' also: while read line; do # operate on "$line" done