👋 Errors, improvements or other cool stuff? Let me know! 😀
Format: -exec <command> <terminator>
{}
: Is replaced by the current file name being processed. It doesn't have to be quoted ("{}"
).\;
: As;
has a meaning for the shell, it must be escaped forfind
to get it.
\;
vs. +
:
-
With
;
, the command is executed on each matched item.Command:
find . -type f -exec echo {} \; | wc -l
Similar to:echo 1; echo 2; echo 3
Result:3
-
With
+
, the command is executed once with the list of all the matched items.Command:
find . -type f -exec echo {} + | wc -l
Similar to:echo 1 2 3
Result:1
find . -regextype posix-extended -regex "<regex>"
find . -name ".DS_Store" -delete
find . -type d -name "foo" -exec rm -fr {} +
find . -maxdepth 2 -name ".git*" -exec rm -rf {} \;
find . -name "Icon?" -print0 | xargs -0 rm
find -L . -type l
find . -type f -name "*.py" -exec sed -i 's/find/replace/g' {} \;