I have a bash script that tries to call pgrep with arguments (Over simplified):
PATTERN="'/opt/apps/bin/lighttpd.bin -f /opt/apps/etc/lighttpd/lighttpd.conf\$'"
pgrep -f $PATTERN
echo pgrep -f $PATTERN
Gives the following output:
Usage: pgrep [-cflvx] [-d DELIM] [-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]
[-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]
pgrep -f '/opt/apps/bin/lighttpd.bin -f /opt/apps/etc/lighttpd/lighttpd.conf$'
I suppose it means the argument is not passed to pgrep but is passed to echo for some reason.
What I'm expecting:
7632
pgrep -f '/opt/apps/bin/lighttpd.bin -f /opt/apps/etc/lighttpd/lighttpd.conf$'
When I run the preg line by itself, it outputs 7632 as expected.
Am I doing something wrong here? I've tried with sh, dash and bash. Same outcomes, I really don't see the problem.