LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Escape character not working in shell script (https://www.linuxquestions.org/questions/programming-9/escape-character-not-working-in-shell-script-175921/)

philipz 04-29-2004 08:48 AM

Escape character not working in shell script
 
Anyone a clue why I get the following error message in this shell script:

-bash-2.05b$ more test | awk '{print "SELECT * FROM sitelist WHERE A LIKE " \" $1 "." $2 "." $3 \" }'
awk: cmd. line:1: {print "SELECT * FROM sitelist WHERE A LIKE " \" $1 "." $2 "." $3 \" }
awk: cmd. line:1:---------------------------------------------^ backslash not last character on line

Apparently the backslash is not interpreted as an escape character here :(
(I put the '-' there myself because the error message was pointing wrong in my copy-paste)

Thx,

Philip

huibert.alblas 04-29-2004 09:58 AM

hi,

looks like you did not close the print statement in awk.
Dont use a DOT . for stringconcat,
it is not needed in awk

This works:

echo "AA BB CC" | awk '{print "SELECT * FROM sitelist WHERE A LIKE "$1" "$2" "$3" "}'

and results in:

SELECT * FROM sitelist WHERE A LIKE AA BB CC

You get the point?


All times are GMT -5. The time now is 07:21 AM.