back toc next

Lists of Commands

A list is a sequence of one or more pipelines separated by one of the operators ';', '&', '&&', or '||', and optionally terminated by one of ';', '&', or a newline.

list1 ; list2

list2 is executed after list1 is terminated
a="Hello World"; echo $a

list1 & [list2]

list1 is executed in the background
sleep 3 & echo I\'m here

list1 && list2

list2 will be executed only if list1 has exit code 0
test -f "$file" && wc -l $file

list1 || list2

list2 will be executed only if list1 has a non zero exit code
test -f "$file" || echo file $file does not exist