[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Awk quoting within shell scripts (was X window to foreground)
- Subject: [ale] Awk quoting within shell scripts (was X window to foreground)
- From: brian at polibyte.com (Brian Pitts)
- Date: Sun Dec 30 00:42:33 2007
- In-reply-to: <[email protected]>
- References: <1198808614.10142.4.camel@localhost> <[email protected]> <[email protected]>
The wmctrl program is packaged for debian and ubuntu and seems pretty
cool. I was trying to write a script with it when I ran into some issues
with shell quoting and awk.
#!/bin/sh
for PID in $(pgrep $1)
do
for WINDOW in $(wmctrl -lp | awk '/$PID/ {print $1}')
do
wmctrl -iR $WINDOW
done
done
The above shows what I tried to accomplish: given a process name as the
argument, for every PID it has raise the associated windows. Of course
it doesn't work since $PID isn't expanded within single-quotes. However,
I can't make awk work with double-quotes no matter how creative I get.
My workaround is
wmctrl -lp | grep $PID | cut -d " " -f 1
but I'd love to know how to do it right with awk. Suggestions?
-Brian