Answer the question
In order to leave comments, you need to log in
How to properly escape quotes in bash?
There is a bash script that contains this variable:
Q='SELECT *
FROM blabla.users s
LEFT JOIN auth.users u on s.userId = u.userId
WHERE
s.userId is not NULL and
not( (u.email like "[email protected]%" OR u.email like "[email protected]%") ) and u.deactivated is NULL
INTO OUTFILE '/home/blalba/$F.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
'
+ Q='SELECT *
FROM blabla.users s
LEFT JOIN auth.users u on s.userId = u.userId
WHERE
s.userId is not NULL and
not( (u.email like "[email protected]%" OR u.email like "[email protected]%") ) and u.deactivated is NULL
INTO OUTFILE /home/blabla/Пт_июл__8_13:20:37_MSK_2016.csv
FIELDS TERMINATED BY ,
LINES TERMINATED BY \n;
'
Answer the question
In order to leave comments, you need to log in
Single quote is not escaped, use double quotes
F="asd";
Q="SELECT *
FROM blabla.users s
LEFT JOIN auth.users u on s.userId = u.userId
WHERE
s.userId is not NULL and
not( (u.email like \"[email protected]%\" OR u.email like \"[email protected]%\") ) and u.deactivated is NULL
INTO OUTFILE '/home/blalba/$F.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
"
echo "$Q"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question