Code Comments
Programming Forum and web based access to our favorite programming groups.Can someone help me with creating a script for the following scenario... search through multiple files with text: ------------------------------------------------------- texttexttexttexttexttexttexttexttexttext texttext texttexttexttexttexttexttexttexttexttext texttext thedir="hello" texttexttexttexttexttexttexttexttexttext texttext texttexttexttexttexttexttexttexttexttext texttext ------------------------------------------------------- find in each file the string: thedir="hello" hold anything between the quotes in a buffer: hello replace the string with a new string + buffer + string: thedir="\hello\" Thank you for any help.
Post Follow-up to this message
david wrote:
> Can someone help me with creating a script for the following
> scenario...
>
> search through multiple files with text:
>
> -------------------------------------------------------
> texttexttexttexttexttexttexttexttexttext
texttext
> texttexttexttexttexttexttexttexttexttext
texttext
> thedir="hello"
> texttexttexttexttexttexttexttexttexttext
texttext
> texttexttexttexttexttexttexttexttexttext
texttext
> -------------------------------------------------------
>
> find in each file the string: thedir="hello"
> hold anything between the quotes in a buffer: hello
> replace the string with a new string + buffer + string:
> thedir="\hello\"
>
> Thank you for any help.
>
gawk '{$0=gensub(/(thedir=\")([^"]*)(\")/,"\\1\\\\\\2\\\\\\3","g")}1' file
Regards,
Ed.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.