LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-18-2015, 03:01 AM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Rep: Reputation: 61
Lightbulb 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!
 
Old 02-18-2015, 03:17 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
1 members found this post helpful.
Old 02-19-2015, 09:40 PM   #3
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Original Poster
Rep: Reputation: 61
Quote:
Originally Posted by syg00 View Post
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.
 
Old 02-19-2015, 09:47 PM   #4
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Original Poster
Rep: Reputation: 61
Quote:
Originally Posted by syg00 View Post
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.
 
Old 02-19-2015, 10:02 PM   #5
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Original Poster
Rep: Reputation: 61
I figured it out!

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to replace "ö" to "p" in shell scripting with "sed" meninmech Programming 5 06-22-2012 02:58 PM
sed - use sed to replace multiple instances from "x" to "y" in a line mrodmac Linux - General 4 02-02-2010 11:37 AM
Can someone give me the definition of "Kernel Symbol" and "EXPORT_SYMBOL" ?? Raynus Programming 2 08-30-2008 07:19 PM
avgscan "relocation error" "undefined symbol: __dynamic_cast_2" Monster_user Linux - Software 0 02-22-2006 11:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration