command1 && command2
In above "&&" case command2
will be executed if and only if command1
returned
zero exit status.
command1;command2
In above ";" case ";" is just a command separator. Thus command2
will be
executed whatever command1
returned.
$> [[ "a" = "b" ]] && echo ok
$> [[ "a" = "b" ]]; echo ok
ok
source: https://unix.stackexchange.com/questions/37069/what-is-the-difference-between-and-when-chaining-commands