Common Delimiters in Terminal Commands on Linux

Semicolon ; Executes the two commands sequentially, regardless of whether the previous command was successful.Example: # First list the contents of the current directory, then switch to the /home directory

ls; cd /home

Logical AND && Only executes the next command if the previous command was successful (returns a 0 status code).Example: # Only enter the directory if mkdir successfully creates it

mkdir test && cd test

Logical OR || Only executes the next command if the previous command failed (returns a non-zero status code).Example: # If the directory already exists (mkdir fails), output a prompt message

mkdir test || echo "Directory already exists"

Leave a Comment