Help! Script or commanded needed to replace text in a file
I am relatively new to linux. I need to replace occurences of chars (", ', `, and \) with (\", \', \`, and \\). I do not know of a linux function that will do that, only a PHP one which is str_replace. I need these characters changed to the new ones because PostgreSQL and MySQL dont recognize these characters. Any help i can get would be great. I assume i will have to use sed or gawk but i am completely unfamilier with how those work.
Thanks, -farmerjoe |
This works for me... know in the business as a 'perl one-liner'. Perl's kind of touchy on one-liners... it'll probably work for you, but I can't guarantee it.
On the command line: Code:
perl -i.bak -pe "s/([\"\'\`\\\])/\x5c\$1/g" /tmp/test.txt |
Re: Help! Script or commanded needed to replace text in a file
Quote:
See http://www.php.net/manual/en/functio...ape-string.php If you're not using PHP, you may find a similar function for your language. |
thanks a lot for all your help! the perl script worked nicely! couldnt have done it without you.
-farmerjoe |
All times are GMT -5. The time now is 01:13 AM. |