[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] sed head scratcher
- Subject: [ale] sed head scratcher
- From: lists at serioustechnology.com (Geoffrey)
- Date: Tue, 04 Aug 2009 16:36:43 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
Jim Kinney wrote:
> breakout the greybeards....
>
>
> I have a pile of text lines that need to have a certain portion
> transposed from upper case (windows dweebs did the hostnames) to lower
> case.
>
> So many lines like:
>
> 192.168.0.2 MACHINE102
> 192.168.3.4 MACHINE304 FredsBox
> 10.0.2.3 MACHINE599 TestingSystemB
> etc
>
> So varying IP address then varying spaces then upper case name with
> digits then varying spaces and sometimes followed by other name with
> mixed case.
>
> I want to ONLY lower case the names after the IP address, not anything
> else in the line.
>
> Here's what I have so far:
>
> cat /etc/hosts | sed '/ [A-Z]{7}[0-9]{1,3}/ y/[A-Z]/[a-z]/'
Sounds like a job for tr:
cat /etc/hosts |tr '[A-Z]' '[a-z]'
--
Until later, Geoffrey
Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
- Benjamin Franklin