[ale] Need AWK Guru input
Geoffrey Myers
lists at serioustechnology.com
Mon Aug 1 16:32:47 EDT 2011
The Don Lachlan wrote:
> On Mon, Aug 01, 2011 at 03:49:35PM -0400, Geoffrey Myers wrote:
>> The Don Lachlan wrote:
>>> $ lsb_release -r | cut -d'.' -f1
>> Your script produces:
>> Release: 5
>> Whereas, the second returns:
>> 5.4
>> I'm pretty sure the OP didn't want the 'Release:' in the output.
>> I think the OP needs to be more specific as to what they want.
>
> Awesome. Thanks for the correction. I misread something earlier (I haz no
> RHEL boxes to test on today) and didn't consider the text leading the ':'.
>
> That colon is a BIG gimme for parsing, though the whitespace sucks. I'd say
> it's still much better than keeping track of syntax in /etc/redhat-release.
>
> $ lsb_release -r | cut -d ':' -f2 | tr -d "\011" | cut -d '.' -f1
>
> Or, if the whitespace bugs you (it bugs me):
>
> $ lsb_release -r | awk '{print $NF}' | cut -d '.' -f1
lsb_release -r | awk -F '[:.]' '{print $(NF-1)}'
:)
--
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