Bash Cheatsheet
Navigate, search, and automate tasks in the terminal with the most useful Bash commands.
Navigation
| Key / Code | Description |
|---|---|
| pwd | Print working directory. |
| ls -la | List files with details. |
| cd ~/projects | Change directory. |
| cd - | Go back to previous directory. |
Files & Folders
| Key / Code | Description |
|---|---|
| touch file.txt | Create a file. |
| mkdir -p app/src | Create nested folders. |
| cp -r src dist | Copy recursively. |
| mv old new | Move or rename. |
| rm -rf temp | Remove files or folders. |
Search & Text
| Key / Code | Description |
|---|---|
| grep -R "TODO" . | Search recursively. |
| find . -name "*.ts" | Find files by name. |
| sed -n '1,20p' file | Print a line range. |
| awk '{print $1}' file | Extract columns. |
Pipes
Chain commands to transform data.
cat access.log | grep 500 | sort | uniq -c | sort -nrScripting Basics
Quick helpers for automation.
#!/usr/bin/env bash
set -euo pipefail
NAME=devref
echo "Hello $NAME"
for f in *.log; do
echo "Processing $f"
doneKnowledge is power.