From owner-freebsd-questions Tue May 15 19:35:40 2001 Delivered-To: freebsd-questions@freebsd.org Received: from grumpy.dyndns.org (user-24-214-76-217.knology.net [24.214.76.217]) by hub.freebsd.org (Postfix) with ESMTP id 8831237B423 for ; Tue, 15 May 2001 19:35:37 -0700 (PDT) (envelope-from dkelly@grumpy.dyndns.org) Received: from localhost (localhost [127.0.0.1]) by grumpy.dyndns.org (8.11.3/8.11.3) with ESMTP id f4G2Xec01850; Tue, 15 May 2001 21:34:02 -0500 (CDT) (envelope-from dkelly@grumpy.dyndns.org) Message-Id: <200105160234.f4G2Xec01850@grumpy.dyndns.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: "Don O'Neil" Cc: freebsd-questions@FreeBSD.ORG From: David Kelly Subject: Re: Help w/ Awk In-reply-to: Message from "Don O'Neil" of "Tue, 15 May 2001 18:09:34 PDT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 15 May 2001 21:33:40 -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "Don O'Neil" writes: > I'm trying to write a simple script to extract the user name, UID and GID of > each user in the /etc/passwd file and I'm not quite sure what I'm doing > wrong here.... here's a code snippet; Let awk parse the entire passwd file. Don't bother launching awk for each and every line, its wasteful. Try this on for size: grumpy: {1013} cat junk.awk #!/usr/bin/awk -f BEGIN { FS =":" } { print $1 } grumpy: {1014} ./junk.awk /etc/passwd # $FreeBSD # root toor daemon operator ... Or better yet with a trival mod to drop the # lines: grumpy: {1023} cat junk.awk #!/usr/bin/awk -f BEGIN { FS =":" } !/^\#/ { print $1 } grumpy: {1024} ./junk.awk /etc/passwd root toor daemon operator ... -- David Kelly N4HHE, dkelly@hiwaay.net ===================================================================== The human mind ordinarily operates at only ten percent of its capacity -- the rest is overhead for the operating system. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message