Почти все знают очень полезные && и || операторы, например:
rm myf && echo "File is removed successfully" || echo "File is not removed"
У меня вопрос: как поставить блок команд после && или || операторы без использования функции?
Например, я хочу сделать:
rm myf && \
echo "File is removed successfully" \
echo "another command executed when rm was successful" || \
echo "File is not removed" \
echo "another command executed when rm was NOT successful"
Каков правильный синтаксис этого сценария?
rm myf && {
echo "File is removed successfully"
echo "another command executed when rm was successful"
} || {
echo "File is not removed"
echo "another command executed when rm was NOT successful"
}
или лучше
if rm myf ; then
echo "File is removed successfully"
echo "another command executed when rm was successful"
else
echo "File is not removed"
echo "another command executed when rm was NOT successful"
fi