Concise Bash Features and Syntax Sheet
Work in progress
Builtins
: or true: These commands do nothing at all. They are NOPs that always return successfully.
false: The same as above, except that the command always "fails". It returns an exit code of 1 indicating failure.
alias: Sets up a Bash alias, or print the bash alias with the given name.
- Aliasses replace a word in the beginning of a command by something else. They only work in interactive shells (not scripts).
cd: Changes the current directory to the given path. If the path doesn't start with a slash, it is relative to the current directory.
. or source: Makes Bash read the filename given as first argument and execute its contents in the current shell (kind of like include in other languages). If more arguments are given than just a filename to source, those arguments are set as the positional parameters during the execution of the sourced code.
- If the filename to source has no slash in it, PATH is searched for it.
bg: Send the previous job (or job denoted by the given argument) to run in the background. (The shell continues to run while the job is running. The shell's input is handled by itself, not the job.)
fg: Send the previous job (or job denoted by the given argument) to run in the foreground. (The shell waits for the job to end and the job can receive the input from the shell.)
break: Break out of the current loop. When more than one loop is active, break out the last one declared. When a number is given as argument to break, break out of number loops, starting with the last one declared.
continue: Skip the code that is left in the current loop and start a new iteration of that loop. Just like with break, a number may be given to skip out more loops.