SBI*_*SBI 18
你可以查看cp的返回码.从cp手册页:
EXIT STATUS
The cp utility exits 0 on success, and >0 if an error occurs.
Run Code Online (Sandbox Code Playgroud)
最后一个操作的退出代码存储在特殊变量$?中,因此您可以执行以下操作:
cp .. ..
echo $? >> outputfile
Run Code Online (Sandbox Code Playgroud)
最有可能的是,您会想要出现某种"自定义"错误消息.为此,您可以检查$的值?
cp .. ..
if [ $? -ne 0 ]
then
echo "there was an error" >> outputfile
fi
Run Code Online (Sandbox Code Playgroud)
我希望能让你开始.
| 归档时间: |
|
| 查看次数: |
14793 次 |
| 最近记录: |