Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
- To: "MLUG Members" <EMAIL:PROTECTED>
- Subject: Re: [MLUG] perl question
- From: "Mark Rages" <EMAIL:PROTECTED>
- Date: Tue, 2 May 2006 00:54:10 -0500
- Delivery-date: Mon, 01 May 2006 23:54:32 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=M65yNTdHa4mF/GnDoIcHQ7Tr5aQ/p1uok83OfD2fKU1o79TdFRMhQQggfu4KOv2KcOSdBKPF3aflyRx6Cf0tqD2Ric8W9VnXIff09IviYdFXXP/zYVOCDGoCq1YZRsWS1Qk+vadejASvrDMIUOcbsZ30z44pPC7rRcdXBYd8gM4=
- Envelope-to: EMAIL:PROTECTED
- In-reply-to: <EMAIL:PROTECTED>
- References: <EMAIL:PROTECTED>
- Reply-to: MLUG Members <EMAIL:PROTECTED>
- Sender: EMAIL:PROTECTED
On 5/2/06, Mike Miller <EMAIL:PROTECTED> wrote:
This must be something I can do in a one-liner: Suppose I have a file
where I want to remove all occurances of a certain character from lines
that match a pattern, like all 'x' characters from every line that begins
with '1':
3 7 x 5 x 9
1 x 2 2 z x
9 9 9 x 9 9
1 2 23 x 7
Maybe I want to replace every 'x' with a space only when the first
character in the line is a '1', otherwise I leave the x's alone. Any
ideas?
The way I would do it is lame: Remove the lines beginning with 1, process
them, then put them back. I would do egrep twice (once with -v), maybe
using cat -n to add line numbers, then take out the x's and put them back
together, sort, take out the line numbers. That is embarrassing though.
Mike
why make it unreadable?
here's Python:
import sys
for ln in sys.stdin:
if ln[0]=='1':
print ln.replace('x',' '),
else:
print ln,
--
You think that it is a secret, but it never has been one.
- fortune cookie
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members