๐Ÿš Bash Dictionary

Every keyword, operator, and symbol explained.

#!/bin/bash shebang
First line โ€” tells OS to use bash interpreter.
#!/bin/bash
set -e option
Exit immediately if any command fails.
set -e
set -u option
Treat unset variables as errors.
set -u
syntax
Expands variable value. Always quote: .
echo 
syntax
Command substitution โ€” runs command, uses output.
DATE=2026-09-17
| operator
Pipe โ€” passes stdout to stdin of next command.
ls | grep go
> operator
Redirect stdout to file, overwriting it.
echo hi > file.txt
>> operator
Redirect stdout, appending to file.
echo hi >> log.txt
&& operator
Run next only if previous succeeded.
make && ./run
if/then/fi syntax
Conditional โ€” runs block if condition true.
if [ -f f ]; then echo ok; fi
for/do/done syntax
Loop over list or glob.
for f in *.txt; do echo ; done
echo command
Prints text to stdout.
echo Hello
grep command
Searches for pattern in files or stdin.
grep -r error logs/
find command
Finds files matching criteria.
find . -name *.log -delete
curl command
Transfers data from/to URLs.
curl -sL https://example.com