[ale] Read multiple variables

leam hall leamhall at gmail.com
Thu Sep 12 12:31:29 EDT 2013


Now that's pretty cool. My awk is a bit rusty, did not know that. Not
surprised that awk can do it, just didn't know how.

Leam


On Thu, Sep 12, 2013 at 12:25 PM, Ed Cashin <ecashin at noserose.net> wrote:

> I bet you know already, but for completeness I guess it's worth mentioning
> that awk can do it all, from the grep part to the while loop.
>
> [ecashin at herlihy ~]$ awk -vuser=ecashin -F: '$1==user{print "U is " $1 ",
> G is " $4 ", and it\x27s " $5}' /etc/passwd
> U is ecashin, G is 1000, and it's Ed Cashin
> [ecashin at herlihy ~]$
>
>
>
> On Thu, Sep 12, 2013 at 8:35 AM, leam hall <leamhall at gmail.com> wrote:
>
>> Well, I used to know how to do this. Trying to get multiple variables set
>> in one line:
>>
>> while read UID GID COMMENT
>> do
>>  echo UID is $UID, GID is $GID, and it's $COMMENT"
>> done < grep person /etc/passwd | awk -F":" '{ print $3, $4, $5 }'
>>
>> Does not work well at all. Any ideas?
>>
>> Thanks!
>>
>> Leam
>>
>> --
>> Mind on a Mission <http://leamhall.blogspot.com/>
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>>
>
>
> --
>   Ed Cashin <ecashin at noserose.net>
>   http://noserose.net/e/
>   http://www.coraid.com/
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>


-- 
Mind on a Mission <http://leamhall.blogspot.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20130912/b79c6a17/attachment.html>


More information about the Ale mailing list