Search and audit content
Use find to walk a page tree, then filter paths with a pipe or search page bodies with -exec grep.
Search page bodies in a tree
Section titled “Search page bodies in a tree”$ find . -exec grep -i 'old product name'$ find ./Docs -maxdepth 2 -exec grep error$ find -name '*Notes*' -exec grep -i TODO$ find ./Docs -exec grep -c errorEach matching page is introduced with its path, then the matching lines. With -c, Shell prints path:count and omits pages with no matches.
This is not the same as filtering find’s output:
| Command | What it searches |
|---|---|
find … | grep PATTERN | Path strings (titles / paths) |
find … -exec grep PATTERN | Page bodies of the pages find enumerates |
-exec supports grep only. Reuse grep’s -i / -v / -n / -c.
Related: grep
Count pages and sample a tree
Section titled “Count pages and sample a tree”$ tree ./Docs$ tree -L 2$ find ./Docs | wc$ find . -maxdepth 1$ find ./Docs | head 20$ ls | sort -r | head 5tree prints an ASCII page tree (default depth 3; use -L / --maxdepth to change it). find prints the start path, then descendants, so find ./Docs | wc is one plus the number of descendants (subject to the caps below). The default -maxdepth for find is 5 if you omit it.
wc prints a line count (wc and wc -l are the same). sort is a lexicographic sort; -r reverses it.
Inspect one page
Section titled “Inspect one page”$ grep -n keyword ./page$ grep -c keyword ./page$ cat ./page | head 20$ cat ./page | grep -i error | head 20You can pass a page path directly to grep, head, or tail, or pipe cat into those filters.
- Results are capped at 5000 paths. Child API fetches are capped at 250 per
find. If a cap is hit, Shell prints what it collected and a marker asking you to refine with-maxdepthor-name. -exec grepfetches at most 100 page bodies.- While a command shows working…, press Esc or Ctrl+C to interrupt it.