Setting Multiple Shell Variables from One Run of awk
- From: Martin McCormick <martin@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Sep 2008 13:48:46 -0500
Right now, I have a shell script that does the following:
hostname=`echo $NEWDEV |awk 'BEGIN{FS="."}{print $1}'`
domain=`echo $NEWDEV |awk 'BEGIN{FS="."}{print $2}'`
top0=`echo $NEWDEV |awk 'BEGIN{FS="."}{print $3}'`
top1=`echo $NEWDEV |awk 'BEGIN{FS="."}{print $4}'`
That looks inefficient (dumb) so I ask, is there a way
to assign the fields in an awk expression to shell variables as
one runs awk once?
Being able to do that would mean one run of awk instead
of the 4 shown here and, if file accesses are involved, there is
only one of those.
Thanks.
Martin McCormick WB5AGZ Stillwater, OK
Systems Engineer
OSU Information Technology Department Telecommunications Services Group
--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
- Follow-Ups:
- Re: Setting Multiple Shell Variables from One Run of awk
- From: Mumia W..
- Re: Setting Multiple Shell Variables from One Run of awk
- From: Bob McGowan
- Re: Setting Multiple Shell Variables from One Run of awk
- From: Ken Irving
- Re: Setting Multiple Shell Variables from One Run of awk
- From: Bob McGowan
- Re: Setting Multiple Shell Variables from One Run of awk
- Prev by Date: Re: How to determine the domain on LAN?
- Next by Date: Re: KDE subpixel hinting
- Previous by thread: how to create an image of your debian computer hard drive for cloning
- Next by thread: Re: Setting Multiple Shell Variables from One Run of awk
- Index(es):
Relevant Pages
|