problem with shell script
rhml at kibug.org
Wed Jan 12 16:50:25 UTC 2011
(2011/01/12 23:01), Frank Bonnet wrote:
> I'm in trouble with a simple shell script that give
> erroneous value when running ...
> If I run commands interactively everything runs well
> > ps ax | grep slapd | grep -v grep | wc -l
> If I run in the following shell script :
> SD=`ps -ax | grep slapd | grep -v grep | wc -l`
> echo $SD
> the result is 3 !!!
> Any info welcome !
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"
i would rather use pgrep(1);
pgrep -afl slapd
for just counting purpose,
pgrep -a slapd | wc -l
is enough. it should work as expected in `` output.
More information about the freebsd-questions