Skip to content

Instantly share code, notes, and snippets.

@SantoshCode
Created February 7, 2022 13:14
Show Gist options
  • Save SantoshCode/342d12482040d9dd46b74b78012d6e6d to your computer and use it in GitHub Desktop.
Save SantoshCode/342d12482040d9dd46b74b78012d6e6d to your computer and use it in GitHub Desktop.
Difference between "&&"and ";" in linux command line

Difference between && and ; ?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment