为什么这个while循环执行完echo while00 && echo while01后不break
while $(sleep 0.5); do pgrep -f baidu > /dev/null 2>&1 || (echo while00 && echo while01 && break); done
监听进程退出后,执行后面的命令
比如ping -c 10 -i 1 baidu.com
怪我咯2017-04-17 12:03:12
(...)
creates a subshell, so break
doesn't work.
In fact, according to the intention of your code, it is completely fine not to write brackets here. Just remove the brackets.
P.S. The while $(sleep 0.5)
you wrote earlier is a misuse of the shell command. You should write while sleep 0.5
here, and adding a $
is unnecessary.