[ale] Need AWK Guru input

Geoffrey Myers lists at serioustechnology.com
Mon Aug 1 14:08:13 EDT 2011


Dennis Ruzeski wrote:
> Something like this?
> 
> cat /etc/redhat-release |awk  '/release/ { for (x=1;x<=NF;x++) if
> ($x~"release") print $(x+1) }'

Just curious, why do you cat the file to awk when you can simply pass 
the file name to awk on the command line?
???

It's a wasted process.

How about:

awk '/release 5/ {print "RHEL 5\n"}
	/release 4/ {print "RHEL 4\n"}' /etc/redhat-release

That is assuming that 'release N' is always in that file indicating the 
version.

> 
> --Dennis
> 
> 
> 
> On Mon, Aug 1, 2011 at 10:52 AM, Chuck Payne <terrorpup at gmail.com> wrote:
>> Guys,
>>
>> I am working on adding servers to my Satellite server, and I like to
>> be able to get in with a script and call on the following
>>
>> /etc/redhat_release
>>
>> But I only want to get the number, so that I can see if it RHEL 4 or
>> 5, I been trying to do with awk, but I am not able to get anything,
>> what is the best way to only put numbers?
>>
>> --
>> (678) 636-9678
>> -----------------------------------------
>> Discover it! Enjoy it! Share it! openSUSE Linux.
>> -----------------------------------------
>> openSUSE -- en.opensuse.org/User:Terrorpup
>> openSUSE Ambassador/openSUSE Member
>> skype,twiiter,identica,friendfeed -- terrorpup
>> freenode(irc) --terrorpup/lupinstein
>> Register Linux Userid: 155363
>>
>> Have you tried SUSE Studio? Need to create a Live CD,  an app you want
>> to package and distribute , or create your own linux distro. Give SUSE
>> Studio a try. www.susestudio.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
>>
> 
> _______________________________________________
> 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


-- 
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson


More information about the Ale mailing list