From owner-freebsd-questions Tue May 15 18:24:36 2001 Delivered-To: freebsd-questions@freebsd.org Received: from MPI-Softtech.Com (mpi.mpi-softtech.com [208.60.120.177]) by hub.freebsd.org (Postfix) with ESMTP id B2A3D37B423 for ; Tue, 15 May 2001 18:24:33 -0700 (PDT) (envelope-from dleimbac@MPI-Softtech.Com) Received: from mpi.mpi-softtech.com (mpi.mpi-softtech.com [208.60.120.177]); by MPI-Softtech.Com (8.9.3/8.9.3/MPI-Softtech/evision: 1.3 $) with SMTP; id UAA18584; Tue, 15 May 2001 20:24:00 -0500 (CDT) Message-Id: <200105160124.UAA18584@MPI-Softtech.Com> Date: Tue, 15 May 2001 20:24:00 -0500 (CDT) From: Dave Leimbach Reply-To: Dave Leimbach Subject: Re: Help w/ Awk To: don@whtech.com Cc: questions@freebsd.org MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: 5bd4qxLBRxtJM2dpjo9h7g== X-Mailer: dtmail 1.3.0 CDE Version 1.3 SunOS 5.7 sun4u sparc Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG read man for awk... look for field separator... :) have a nice day. Dave >Delivered-To: freebsd-questions@freebsd.org >From: "Don O'Neil" >To: >Subject: Help w/ Awk >Date: Tue, 15 May 2001 18:09:34 -0700 >MIME-Version: 1.0 >Content-Transfer-Encoding: 7bit >X-Priority: 3 (Normal) >X-MSMail-Priority: Normal >X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 >Importance: Normal >X-Loop: FreeBSD.ORG > >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; > >#!/bin/sh >passwd=`cat /etc/passwd` > >for user in $passwd > >do > >username=`echo $user | awk 'BEGIN { FS=":" } END { print $1 }'` > >echo $username > >done > > >Where am I going wrong with awk? Sometime the result of $username is the >user name, but sometimes its another part of the entry in the file. I just >want the user name stuck into username. > >Thanks! > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message