bash multiple commands one line
# Basic syntax: # This will run command_2 after command_1 regardless of whether command_1 # completes successfully or not: command_1; command_2 # This will run command_2 after command_1 if command_1 completes successfully: command_1 && command_2 # This will run command_2 after command_1 if command_1 fails: command_1 || command_2 # This will pass (pipe) the standard output of command_1 to command_2: command_1 | command_2
Source: dev.to
bash for loop multiple commands one line
# Basic syntax: for i in a b; do echo $i; printf "$i\t$i\n"; done # Where: # - each command in the for loop needs to be separated by semicolons. Here # we echo $i and then print $i<tab>$i<newline> # - over several lines this would be equivalent to: for i in a b do echo $i printf "$i\t$i\n" done
Source: ma.ttias.be