i try to find a specific process containing the term "someWord" and two other terms represented by $1 and $2
7 regex="someWord.*$1.*$2"
8 echo "$regex"
9 [ `pgrep -f $regex` ] && return 1 || return 0
which returns
./test.sh foo bar
someWord.*foo bar.*
./test.sh: line 9: [: too many arguments
What happens to my regular expression? Doing that pgrep directly in the shell works fine.
Good sir, perhaps this
[[ `pgrep -f "$regex"` ]] && return 1 || return 0
or this
[ "`pgrep -f '$regex'`" ] && return 1 || return 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With