On Thu, Nov 29, 2007 at 08:16:39PM -0500, Douglas W McKibbin wrote:
> I want to find a number located in a text file and replace it with  
> the line number of the line where the number resides-2.  The number  
> to find is located in the only line that starts with "SE*"and resides  
> between the first and second "*" in the line ..... eg  in line  
> SE*165*29799905~of the text file the number to replace would be 165  
> and the replacement number would be the line number of the  
> SE*165*2799905~ line-2.  I think this is pretty simple but I'm not at  
> all familiar with grep and only mildly literate with applescript.   
> Thanks for any help.
> Douglas McKibbin 

Here's a way to do it in Perl:

#!perl -p

s/^(SE\*)\d+(\*)/$1 . ($. - 2) . $2/e;

__END__


You could save this as a filter, and run it on the contents of a file in
BBEdit.

Or, you could run it against a file from the Terminal; change the first
line to #!perl -pi to modify the file in place.

HTH,
Ronald

-- 
------------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to