LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-15-2012, 01:15 PM   #1
px87
LQ Newbie
 
Registered: Nov 2011
Posts: 18

Rep: Reputation: Disabled
Problem whit special characters in shell script


Hi all!!

I'm trying to run a mysql sentence by a shell script, but I'm having troubles with the special characters:

This is my sentence:

mysql -u root -p123456 -e "GRANT ALL PRIVILEGES ON `$varx\_%` . * TO '$varx'@'localhost' IDENTIFIED BY '54321';"

and the problems are with "_" and "%" I've tried in differents ways, but I can't do it.

I hope you can help me.

Thanks!

Greetings.
 
Old 04-15-2012, 02:51 PM   #2
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Hi
how about:
Code:
mysql -u root -p123456 -e "GRANT ALL PRIVILEGES ON `$varx\_\%` . * TO '$varx'@'localhost' IDENTIFIED BY '54321';"
You've to quote the "%" by "\" too. The "'" maybe also.
Are you sure you want to use "`" or should it be "'"?
 
Old 04-15-2012, 03:04 PM   #3
px87
LQ Newbie
 
Registered: Nov 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sys64738 View Post
Hi
how about:
Code:
mysql -u root -p123456 -e "GRANT ALL PRIVILEGES ON `$varx\_\%` . * TO '$varx'@'localhost' IDENTIFIED BY '54321';"
You've to quote the "%" by "\" too. The "'" maybe also.
Are you sure you want to use "`" or should it be "'"?
Hi! thanks for your answer.

I solved my problem 30 seg. before your answer jeje...

What I did to solve my problem is escape the "`" that is necessary to the mysql sentence:

mysql -u root -p123456 -e "GRANT ALL PRIVILEGES ON \`$varx\_%\` . * TO '$varx'@'localhost' IDENTIFIED BY '54321';"

Thanks a lot for your answer!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I replace special characters in a string within a bash script? rhaup0317 Linux - Newbie 2 06-03-2008 11:56 AM
bash script to find out more than 1 continuous special characters in a file. kkpal Linux - Newbie 1 06-02-2008 04:56 AM
inserting special characters into mysql with bash script ihopeto Linux - Newbie 1 12-05-2006 12:46 PM
how to have no interpretation of special characters (ctrl, tab ...) in a script xround Linux - General 1 11-29-2004 07:21 AM
shell scripting (special characters) synapse Mandriva 4 02-18-2004 06:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:03 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration