Date: Tue, 15 May 2001 18:29:25 -0700 From: "Don O'Neil" <don@whtech.com> To: "Dave Leimbach" <dleimbac@MPI-Softtech.Com>, <don@whtech.com> Cc: <questions@freebsd.org> Subject: RE: Help w/ Awk Message-ID: <MOBBIPGJKBNNPGLGMFHFIEICHCAA.don@whtech.com> In-Reply-To: <200105160124.UAA18584@MPI-Softtech.Com>
next in thread | previous in thread | raw e-mail | index | archive | help
You obviously didn't read my code snippet... it' has the field separator defined as :... neither the method in the code, nor the -F':' option work correctly. When I try to have it print the first field ($1) I sometimes get parts of other fields, like it's ignoring the separator. > -----Original Message----- > From: Dave Leimbach [mailto:dleimbac@MPI-Softtech.Com] > Sent: Tuesday, May 15, 2001 6:24 PM > To: don@whtech.com > Cc: questions@freebsd.org > Subject: Re: Help w/ Awk > > > read man for awk... look for field separator... :) > > have a nice day. > > Dave > >Delivered-To: freebsd-questions@freebsd.org > >From: "Don O'Neil" <don@whtech.com> > >To: <freebsd-questions@FreeBSD.ORG> > >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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?MOBBIPGJKBNNPGLGMFHFIEICHCAA.don>