在bash中如何使这样的结构工作:
if (cp /folder/path /to/path) && (cp /anotherfolder/path /to/anotherpath)
then
echo "Succeeded"
else
echo "Failed"
fi
Run Code Online (Sandbox Code Playgroud)
if应该测试$?返回每个命令的代码并用&&绑定它们.
我怎样才能在Bash中做到这一点?
gho*_*g74 13
if cp /folder/path /to/path /tmp && cp /anotherfolder/path /to/anotherpath ;then
echo "ok"
else
echo "not"
fi
Run Code Online (Sandbox Code Playgroud)
cp /folder/path /to/path && cp /anotherfolder/path /to/anotherpath
if [ $? -eq 0 ] ; then
echo "Succeeded"
else
echo "Failed"
fi