Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
#!/bin/bash fuser /mount/foo echo $? if [ $? = 0 ]; then echo "There are no processes accessing foo." else echo "foo is in use."
回声$?正在返回“1”,因为 fuser 进程正在访问挂载 - 而不是回显“挂载正在使用中”,而是回显“没有进程访问挂载”。除了语法之外,我不确定是什么导致了这种相反的行为,但也许我完全错误地构建了它。
你的第二个$?评估 echo 的结果,应该为 0。删除 echo 或使用变量代替
#!/bin/bash fuser /mount/foo result=$? echo $result if [ $result = 0 ]; then echo "There are no processes accessing foo." else echo "foo is in use."