roger34
roger34

Reputation: 275

Sed usage to eliminate characters around certain patterns but not others

I have a file with thousands of lines marked similar to this:

{3203}

{1293}

{xii}

{xi}

{vii}

etc...

I need to eliminate the brackets around the numbers but not the letters (roman numerals) so in essence it would look like

3203

1293

{xii}

{xi}

{vii}

etc..

I would put up what I've been testing so far, but I'm not especially close to getting any part of the sed statement correct.

Upvotes: 4

Views: 240

Answers (2)

Dan Breen
Dan Breen

Reputation: 12924

Couldn't get it to work with sed, but this works if you have Perl available:

perl -pe 's/{(\d+)}/\1/' inputfile

Upvotes: 0

Mark Wilkins
Mark Wilkins

Reputation: 41232

This might be close to what you are looking for:

sed -e 's/{\([0-9]\+\)}/\1/g' inputfile

Upvotes: 5

Related Questions