File & search commands

Find files by name or size, search inside files, create and extract archives, sync folders with rsync, verify checksums and batch-rename files from the terminal.

17 commands

Find files by name

macOSLinux

Searches the folder and all subfolders for matching names.

find -name ""

Find large files

macOSLinux

Lists files bigger than the size you choose, with their sizes.

find -type f -size + -exec ls -lh {} \; 2>/dev/null

Search text inside files

macOSLinux

Every line containing the text, with file names and line numbers.

grep -rn ""

Fast search with ripgrep

macOSWindowsLinux

Much faster than grep and skips .gitignore’d files. Install with brew install ripgrep.

rg ""

Compress a folder (.tar.gz)

macOSLinux

Creates a compressed archive.

tar -czvf

Extract a .tar.gz

macOSLinux

Unpacks the archive into the current folder.

tar -xzvf

Zip a folder

macOSLinux

Creates a .zip that opens anywhere.

zip -r

Unzip into a folder

macOSLinux

Extracts the zip into the given folder.

unzip -d

Sync two folders

macOSLinux

Copies only what changed and preserves timestamps and permissions. The trailing slash on the source means "its contents".

rsync -avh --progress

Follow a log file live

macOSLinux

Prints new lines as they’re written. Ctrl+C to stop.

tail -f

Count lines in a file

macOSLinux

Number of lines (add -w for words).

wc -l

Checksum a file

macOSLinux

Verify downloads against the published hash. On Linux you can also use sha256sum.

shasum -a 256

Show a folder tree

macOSLinux

Visual folder structure, limited to N levels. Install with brew install tree.

tree -L

Change the extension of many files

macOSLinuxCareful

Renames every .txt in the folder to .md.

for f in *.; do mv -- "$f" "${f%.}."; done

Renames files in place. Try it on a copy first.

Delete all .DS_Store files

macOSLinuxCareful

Removes macOS folder metadata files from the current folder down.

find . -name ".DS_Store" -type f -delete

Delete every node_modules folder

macOSLinuxDestructive

Frees up gigabytes from old projects. Reinstall later with npm install.

find . -name "node_modules" -type d -prune -exec rm -rf {} +

Deletes folders permanently. Run it from your projects folder, not from / or ~.

Every command copies as plain, clean text: no curly quotes, no long dashes, no invisible characters.

Related guides