-   Linux - General (
-   -   how to escape variable in bash??? (

rabbate 03-17-2004 03:01 PM

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:

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????

cyberfunk 03-17-2004 07:30 PM

Can you post the output of the above command, I dont understand what you are trying to achieve.

Cheers :)


rabbate 03-17-2004 07:49 PM

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:||||

I want to be able manipulate that data using bash and plug into procmail to filter it as either authorized emails or blocked emails....

green_dragon37 03-17-2004 08:02 PM

Use sed to replace the '@'s with '/@'s and the '.'s with '/.'s, like so:

var = `echo $var | sed s/@/\\/@/g | sed s/\\./\\/\\./g`


rabbate 03-17-2004 08:04 PM

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.