Safe filesystem operations using only pre-installed system tools. No external dependencies, no network access, no install.
Safety first — always confirm destructive operations before executing.
mv, cp, rm are irreversible without a backupls -la before touching anythingtrash (macOS) or rm as last resortToolPurposeNoteslsList filesAll Unix ✅findSearch filesAll Unix ✅grepSearch file contentsAll Unix ✅cat / head / tailRead filesAll Unix ✅mvMove / renameWrite ⚠️cpCopy filesWrite ⚠️mkdirCreate directoriesWrite ⚠️rmDelete filesWrite ⚠️ last resortstatFile metadataAll Unix ✅duDisk usageAll Unix ✅tarArchive filesAll Unix ✅xattrExtended attributesmacOS ✅
ToolPurposeNotestrashMove to Trash (recoverable)macOS ✅ preferredpbcopy / pbpasteClipboardmacOS ✅mdlsSpotlight metadatamacOS ✅mdutilSpotlight indexmacOS ✅
These are helpful but NOT guaranteed. Check with which <tool> before using:
tree — directory tree view (install: brew install tree)rg (ripgrep) — faster grep (install: brew install ripgrep)fd — faster find (install: brew install fd)dust — better du (install: brew install dust)bat — better cat (install: brew install bat)bash
# Basic listing
ls -la /path/to/dir
# Human-readable sizes, newest first
ls -lahF /path/to/dir | sort -k5 -rh
# Recursive depth
find /path -maxdepth 2 -type f
# Show hidden files
ls -la /path/to/dir
bash
# Find by name pattern
find /path -name "*.txt" -type f
# Case-insensitive
find /path -iname "readme*"
# Modified in last N days
find /path -name "*.md" -mtime -7
# By size
find /path -size +100M
bash
# Grep with context
grep -rn "search_term" /path
# Case-insensitive
grep -ri "search_term" /path
# Only filenames with matches
grep -rl "search_term" /path
bash
# Total size of directory
du -sh /path/to/dir
# Per-subdirectory breakdown
du -h --max-depth=1 /path | sort -rh
# Find largest files (recursive)
find /path -type f -exec du -h {} + | sort -rh | head -20
bash
# Move (rename)
mv source.txt /new/path/
# Copy (recursive for directories)
cp -r /source/dir /dest/dir
# Delete — ALWAYS confirm first
# Preferred on macOS (goes to Trash):
trash /path/to/file.txt
# Or rm as last resort:
rm /path/to/file.txt
bash
# Rename all .txt to .md in current directory
for f in *.txt; do mv "$f" "${f%.txt}.md"; done
# Replace spaces with underscores
for f in *\ *; do mv "$f" "${f// /_}"; done
bash
# Create tar.gz
tar -czvf archive.tar.gz /path
# Extract
tar -xzvf archive.tar.gz
# Create zip
zip -r archive.zip /path
# Extract zip
unzip archive.zip
Read-only operations — safe to execute without asking:
ls, find, grep, cat, head, tail, du, stat, file, mdls
Write operations — always confirm before executing:
mv, cp, mkdir, trash, rm, zip, tar
For destructive operations:
trash over rm on macOSrm -rf / or any recursive delete without confirmingchmod -R 777 or permission changes that break securitysudo operations unless explicitly requestedbash
# Where am I?
pwd
# What's in current directory?
ls -la
# Find all PDFs larger than 10MB
find ~ -name "*.pdf" -size +10M
# How much space is used?
du -sh ~/Library
# Search for TODO in code files
grep -rn --include="*.py" "TODO" ~/code/