GAH! Bash script insanity

Joshua Pollak pardsbane at offthehill.org
Wed Jan 28 16:42:03 EST 2004


Ok, I'm going crazy. I don't know how the script-kiddies deal with bash.

So the advice I got from the list re: my awk problem was great, and I'm 
trying to implement it. Here is what I want to run:

sed -e s/#.*// ${CONFIG_FILE} | awk -F"=" '/${PARAMETER}/ { print $2 }'

The insanity comes from finding the right combination of "s, 's, and `s 
so that $CONFIG_FILE and $PARAMETER are interpreted by the bash script 
interpreter, while $2 is NOT, and is passed to awk, while 
simultaneously keeping the sed and awk commands separate from each 
other (apparently if you try things like:

` '<above string' `

the interpreter passes the | to sed as an argument rather than breaking 
the commands up.

I guess I want something like:

RESULT=`sed -e s/#.*// ${CONFIG_FILE}` | `awk -F"=" '/${PARAMETER}/ { 
print $2 }' `

But I can't quite get it. Its driving me MAD.

Any ideas, besides shooting myself and re-writing this in C or 
hardcoding everything?

-- 
Joshua Pollak
Software Engineer
Charles River Analytics
617-491-3474 x586



More information about the Discuss mailing list