On 15/04/2012 19:45, Herring Dave - dherri wrote: > So "ps -ef|grep -cw $0" returns "3" but "if [ `ps -ef|grep -cw $0` -gt 3 ]" > evaluates to "4". Am I interpreting this correctly in saying that bash forks > another process when evaluating a command as part of an if-test while ksh > does not? Is there a more general way of explaining this difference is shell > processing? [...] I believe this is related to the fact that some shells (the KornShell and Z-Shell) thread the last command in a pipeline differently: [drado@oel62001 t]$ bash -c '(ps -ef|grep -w $0)' drado 2560 2559 0 20:17 pts/0 00:00:00 -bash drado 3164 2560 2 20:42 pts/0 00:00:00 bash -c (ps -ef|grep -w $0) drado 3165 3164 1 20:42 pts/0 00:00:00 bash -c (ps -ef|grep -w $0) drado 3167 3165 3 20:42 pts/0 00:00:00 grep -w bash [drado@oel62001 t]$ ksh -c '(ps -ef|grep -w $0)' drado 3168 2560 3 20:42 pts/0 00:00:00 ksh -c (ps -ef|grep -w $0) drado 3170 3168 1 20:42 pts/0 00:00:00 grep -w ksh From the man pages (KornShell 93 Manual Page - www2.research.att.com/sw/download/man/man1/ksh.html): A /pipeline / is a sequence of one or more /commands / separated by *|*. The standard output of each command but the last is connected by a /pipe/ <http://www2.research.att.com/sw/download/man/man2/pipe.html>(2) to the standard input of the next command. Each command, _except possibly the last_, is run as a separate process; the shell waits for the last command to terminate. P.S. I though that this difference was relative only to shell built in commands tough ... -- //www.freelists.org/webpage/oracle-l