![]() |
how to escape variable in bash???
Hi. I want to be able to see if bash can escape a variable. The
variable will be *dynammically generated* so I can't just manually put in slashes. It will be running mysql command and capturing the output. Example Like this: #!/bin/bash VAR = `mysql -u "user" -B -N -e "SELECT auth FROM table WHERE user='xxxx' " db --password="password"`; echo $VAR; # need it to be escape the "."and "@" can this be done in bash???? |
Can you post the output of the above command, I dont understand what you are trying to achieve.
Cheers :) Cyber |
I am trying to use that returned data and filter it through procmail. Procmail requires data with periods, and @ signs to be escaped. Example of output is from the above query via bash:
@ymdomain.com|info@mysite.com|customersupport@nospam.com|orders@yahoo.net|billing@youcare.net I want to be able manipulate that data using bash and plug into procmail to filter it as either authorized emails or blocked emails.... |
Use sed to replace the '@'s with '/@'s and the '.'s with '/.'s, like so:
var = `echo $var | sed s/@/\\/@/g | sed s/\\./\\/\\./g` Ian |
Of course!!! I totally forgot about sed! I use it for other things, but forgot about the application here. Thanks!!
|
All times are GMT -5. The time now is 03:56 AM. |