The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 08-26-2007
earlysame55 earlysame55 is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 23
Quote:
Originally Posted by steveglevin View Post
Hi,

I really need some help with GREP searching...

I need to find all occurances of a file reference and remove two characters from the end of the reference. For example, here are a few lines showing the text:

<image file="STRAIGHT_004CR.jpg" ALT="STRAIGHT_004CR.jpg" />
<image file="STRAIGHT_006CR.jpg" ALT="STRAIGHT_006CR.jpg" />
<image file="STRAIGHT_007CR.jpg" ALT="STRAIGHT_007CR.jpg" />

And they then need to look like:

<image file="STRAIGHT_004.jpg" ALT="STRAIGHT_004.jpg" />
<image file="STRAIGHT_006.jpg" ALT="STRAIGHT_006.jpg" />
<image file="STRAIGHT_007.jpg" ALT="STRAIGHT_007.jpg" />

I think I've written the correct search query which I think is:

_\d{3}\D\D

But I have no idea how to write the replacement string to remove the additional letters at the end of the string of 3 numbers and leave everything else in tact...

ANy help would be much appreciated...

Thanks

Steve.
Hi,

try using :

sed. sed 's/CR.jpg/.jpg/g'

But make sure you have a backup of the file.
regards