Bash scripting
brackets
One of the comment points out the corresponding terminology in man page. Here are the quick ref for man bash: just search for the Terminology and will jump to the section. For example, /Command Substitution jumps to the dollar single parens section.
| Description | Terminology | Example | Comment |
| ( single parens ) | one of Compound Commands → subshell | (cd a;mkdir b) | doesn’t modify current shell |
| $( dollar single parens ) | Command Substitution | echo $(ls; echo end) | also backticks `command` |
| (( double parens )) | one of Compound Commands → arithmetic expression | ((a=3+4)) | integer arithmetic, equivalent of let, doesn’t output |
| $(( dollar double parens )) | Arithmetic Expansion | a=$((3+4)) | integer arithmetic, variables inside don’t need dollar sign |
| [ single brackets ] | CONDITIONAL EXPRESSIONS | if [ -f file.txt ]; then echo ‘file exists’; fi | only use this for POSIX compatibility, requires spaces around brackets |
| [[ double brackets ]] | CONDITIONAL EXPRESSIONS | [[ -f file.txt ]] | preferred in bash |
| { braces } | Brace Expansion | echo {1..10..3} file{,.bak} | convenient for files with same prefix |
| ${ dollar braces } | Parameter Expansion | ${var:-default} | a whole lot of features for string manipulation |
| <( angle parens ) | Process Substitution | comm -12 <( sort file1 ) <( sort file2 ) | VAR=($( COMMAND )) take output and store as array |