LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Help with "sed" and the $ symbol (https://www.linuxquestions.org/questions/linux-software-2/help-with-sed-and-the-%24-symbol-4175534387/)

wh33t 02-18-2015 03:01 AM

Help with "sed" and the $ symbol
 
Hey LQ,

I'm trying to perform a site-wide mysql upgrade on a webserver. I need to update all of the mysql functions to use mysqli. I have found this nifty command (http://www.isaacsukin.com/news/2013/...iles-directory)

Code:

grep -lr -e "mysql" . | xargs sed -i "s/mysql/mysqli/g"
which works great. However when I try to complete the final part of the update with this command:

Code:

grep -lr -e "mysqli_query(" . | xargs sed -i "s/mysqli_query(/mysqli_query($link,/g"
It doesn't seem to like the word $link. This is the result from it.

Code:

$result = mysqli_query(,$query);
And I figure this is because dollar signs means something to the console. Is there a way I can tell this command to ignore the dollar sign and search for it literally?

Any tips in the right direction would be soooo helpful! Thanks!

syg00 02-18-2015 03:17 AM

Escape the $ (i.e. \$), or use single quotes rather than double quotes. The latter may have other ramifications depending on what else you are doing.

wh33t 02-19-2015 09:40 PM

Quote:

Originally Posted by syg00 (Post 5319258)
Escape the $ (i.e. \$), or use single quotes rather than double quotes. The latter may have other ramifications depending on what else you are doing.

Yes, I have backups. I'm actually performing this testing update on the backup. Thanks for your advice.

wh33t 02-19-2015 09:47 PM

Quote:

Originally Posted by syg00 (Post 5319258)
Escape the $ (i.e. \$), or use single quotes rather than double quotes. The latter may have other ramifications depending on what else you are doing.

Where should I be putting these quotes? When I put single quotes around the dollar symbol it ends up replacing it as '$link' which I do not want.

wh33t 02-19-2015 10:02 PM

I figured it out!

I used a backslash in front of the dollar sign and it worked proper. TY!


All times are GMT -5. The time now is 01:22 AM.