Skip to content
Advertisement

Linux command line for find & replace not working

Im having an issue with this code in the command line:

sed -i 's/row['email']/_SESSION['nen']/g' /var/www/v2-stage/v2-stage/add_on/change_password.php

For some reason i think it isnt working since the ’email’ but that is how the code is & i cant change it. Also im running it through the shell_exec for php. but i tried it directly and it wasnt working as well.

any ideas?

Advertisement

Answer

Because you have ' in your command, you need to use double quote " for sed.

Any char except ' will be literal (which means the will be literal, too), so you can rewrite your command as

sed -i "s/row['email']/_SESSION['nen']/g" /var/www/v2-stage/v2-stage/add_on/change_password.php

If you write your command in a text editor (or notice the color on stackoverflow), the syntax highlight will help you determine the correctness of your command.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement