Linux Paths and Navigation Cheat Sheet/Iterate over files safely

Use NUL delimiters for filenames with spaces/newlines.

Section: Path Recipes

Iterate over files safely

bash
bash
find . -type f -print0 | while IFS= read -r -d '' f; do printf '%s
' "$f"; done

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Path Recipes
Convert relative path to absolute path
Resolve a relative path from current directory.
OpenIn sheetbashsame section
Test whether path exists
Check file or directory existence in shell scripts.
OpenIn sheetbashsame section
Show current path via shell variable
Print current directory using shell state.
OpenIn sheetbash1 tag match
Get basename
Extract the last path component.
OpenIn sheetbash1 tag match
Get dirname
Extract the parent directory path.
OpenIn sheetbash1 tag match
Resolve relative path from base
Produce canonical path using a base directory.
OpenIn sheetbash1 tag match