in reply to spaces in grep command argument executed in backticks
Note the [ ] around one of the characters.$module = "xyz ab[c]"; $pid = `ps -aef|grep \"$module\"|cut -d ' ' -f3`;
If you really wanted the pid rather than the ppid then change the [2] to [1].my $module = 'xyz abc'; my @ppids = map {(split)[2]} grep /$module/,`ps -ef`; print "@ppids\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: spaces in grep command argument executed in backticks
by jwkrahn (Abbot) on Oct 23, 2009 at 21:01 UTC |