advertisement
Forums

The Forum is sponsored by 
 

AAPL stock: Click Here

You are currently viewing the Tips and Deals forum
Need some help with Sed/Perl, trying to remove strings based on Regular Expressions
Posted by: microchip
Date: July 27, 2009 01:46PM
I have a PMWiki and I would like to make the actual PMWiki files a bit more readable.


There parts in the files like "host:093209u029j3r0923r09we0f9i0we" which I would like to remove.

I've trued something along the lines of "cat file | sed 's/diff:.*[^ ]//g'" to no avail.

Any help? Or any better way to attack this?
Options:  Reply • Quote
Re: Need some help with Sed/Perl, trying to remove strings based on Regular Expressions
Posted by: rz
Date: July 27, 2009 02:39PM
I'm a bit rusty on using sed, but I'm confused at the s/diff part. Shouldn't you be searching on "host.*" and replacing it with nothing?
Options:  Reply • Quote
Re: Need some help with Sed/Perl, trying to remove strings based on Regular Expressions
Posted by: microchip
Date: July 27, 2009 02:59PM
There are a few different prefixes of lines, host, diff, I just so happened to post a sample from two separate things.

I tried host* and it would remove whole lines. I just tried perl and it actually worked much better but I had to individually assign each of the numbers:

perl 's/diff:[0-9][0-9].........//g' and so on.

I realized that migrating this content may not be worth the while, so I've put it on the back burner for now.
Options:  Reply • Quote
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 220
Record Number of Users: 186 on February 20, 2020
Record Number of Guests: 5122 on October 03, 2020