Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GAH! Bash script insanity



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




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org