Mehdi Akiki
Published on

Short engineering note

Today I Learnt: Find files with find

Authors
  • Mehdi Akiki avatar
    Name
    Mehdi Akiki
    Twitter

Note · Engineering notes

Find files by name:

find . -name "*.log"

Find and delete empty files:

find . -type f -empty -delete

Run a command safely for each matching file:

find . -type f -name "*.log" -exec printf '%s\n' {} \;

Use -print0 with an option such as xargs -0 when passing paths to a second command in bulk.