Mark Lucernas
Oct 20, 2021

Find: Advanced Usage

find -exec with Multiple Commands

find . -name "*.txt" -exec echo {} \; -exec grep banana {} \;
find . -name "*.txt" \( -exec echo {} \; -o -exec true \; \) -exec grep banana {} \;

NOTE: succeeding commands will only execute if the previous command returned successfully.

Ref

Bulk Renaming

Rename *.abc file matches to *.edefg using ↪ rename unix command.

find /path/to/root -type f -name '*.abc' -print0 | xargs -0 rename 's/.abc$/.edefg/'

Ref:


Resources