[X-Unix] Help with BBEdit Grep find and replace

Eric F Crist ecrist at secure-computing.net
Thu Jan 31 14:51:30 PST 2008


you can do this really easily with a short command in sed, provided  
this text only appears in this one place.

sed -i ".bak" s/W3SVC1823/W3SVC1822/g <filename>

This will replace all instances for the first argument with the second  
argument.  <filename> can contain wild cards, etc.

If you need something more specific, just add text in both arguments  
to make it unique.

sed -i ".bak" s%ogFilePath2=file:///d:\Webtrendslogs\corvette 
\e0182201\W3SVC1823\*.log%ogFilePath2=file:///d:\Webtrendslogs\corvette 
\e0182201\W3SVC1822\*.log%g

You'll note that I've changed the delimiter to a % instead of the /,  
as I'm using the forward and backward slashes in the matched text.

HTH

Eric


On Jan 31, 2008, at 3:32 PM, Nick Scalise wrote:

> Hello,
>
> I posted to this list long ago about some help with grep and I am  
> coming back to the well one more time as the help was excellent last  
> time.
>
> I have some report files that need to be updated and the second line  
> needs to be changed to be similar to the first line:
>
> ServerName=Cobra
> LogFilePath=file:///d:\webtrendslogs\cobra\E0182201\W3SVC1822\*.log
> LogFileUsername=
> LogFilePassword=
> ServerName2=Corvette
> LogFilePath2=file:///d:\Webtrendslogs\corvette 
> \e0182201\W3SVC1823\*.log
>
> What I am looking for is the line that begins with LogFilePath2 to  
> be made to be similar to the line that begins with LogFilePath. In  
> the example above the only differences is the machine name (cobra/ 
> corvette and the w3svc182x)
>
> I want the w3svc182x number to change but not the machine name.
>
> I will be using BBEdit for this (version 8.7.2 (260))
>
> Can anyone provide assistance for me?
>
> TIA
> --
> Nick Scalise
> nickscalise at cox.net
> _______________________________________________
> X-Unix mailing list
> X-Unix at listserver.themacintoshguy.com
> http://listserver.themacintoshguy.com/mailman/listinfo/x-unix

-----
Eric F Crist
Secure Computing Networks




More information about the X-Unix mailing list