[olug] Character Removal
Obi-Wan
obiwan at jedi.com
Fri Oct 19 15:16:23 UTC 2007
> I'd like to remove all characters between a '(' and the second ')'.
Perl has its uses, but is overly bloated for such a simple operation.
Sed(1) does a wonderful job of this sort of thing. Assuming you want
to keep the first and last parentheses:
# echo "abc (asdf) asdf (asdf) 1234 (xyz) 67" | sed -e 's/([^)]*)[^)]*)/()/'
abc () 1234 (xyz) 67
If you don't want to keep those parens, then drop the last pair from
that sed command:
# echo "abc (asdf) asdf (asdf) 1234 (xyz) 67" | sed -e 's/([^)]*)[^)]*)//'
abc 1234 (xyz) 67
--
Ben "Obi-Wan" Hollingsworth obiwan at jedi.com
The stuff of earth competes for the allegiance I owe only to the
Giver of all good things, so if I stand, let me stand on the
promise that You will pull me through. -- Rich Mullins
More information about the OLUG
mailing list