Page 1 of 1

Sed script help

Posted: Thu Nov 15, 2007 1:21 pm
by Phil Hansen
Hi,
Hope this the right forum.
Some time back Jussi helped with a script for deleting HTML tags. Worked fine.
Now have a problem removing the " character from a text file. Tried Sed and modifying the original script but could not get it to remove the offending ".
Eventually used the search and replace but it took 6 hours to find and replace 2500000 instances of " with a blank.
There must be a faster way.
This is to be done every month so any help in speeding it up would be appreciated.
Thanks
Phil

Posted: Thu Nov 15, 2007 10:15 pm
by jussij
Hi Phil,
Tried Sed and modifying the original script but could not get it to remove the offending "
The s/\"/ /g command should work.

For example, given this file data:

Code: Select all

This"is"a"test"string
This"is"a"test"string
This"is"a"test"string
This"is"a"test"string
This"is"a"test"string
Running this sed command:

Code: Select all

sed "s/\"/ /g" test.txt
produces this result:

Code: Select all

This is a test string
This is a test string
This is a test string
This is a test string
This is a test string
Cheers Jussi

Posted: Fri Nov 16, 2007 4:51 am
by Phil Hansen
Hi Jussi,
Thanks for that. Works fine.
I tried /"/, ["], '"' but not \"/.
Got it working from the tools menu and fixes the file in about 30 secs.
Big difference from search and replace.
Thanks again :D

Cheers
Phil