mv封装在if in shell脚本中 [英] mv wrapped inside an if in shell scripting
本文介绍了mv封装在if in shell脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您如何做到这一点?我在想的是这样..另外,我是否需要使用fi并完成操作?或只有其中一个
How do you do this? What I'm thinking is like this.. also, do I need to use fi and done? or only one of them
if[mv 1.txt > 2.txt == '0']
then
echo "Success"
else
echo "Failure"
fi
done
推荐答案
在BASH中,这足够了:
In BASH only this would suffice:
mv 1.txt 2.txt && echo "Success" || echo "Failure"
但是,如果您想使用传统的 if/fi
,请使用
However if you want to use traditional if/fi
then use
if mv 1.txt 2.txt
then
echo "Success"
else
echo "Failure"
fi
这篇关于mv封装在if in shell脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文