Answer the question
In order to leave comments, you need to log in
Using regex in find, how to add "OR" condition?
Good afternoon.
I use the command to keep track of updated files:
find . \( ! -regex '.*/\_logs.*' \) -type f -mtime -1 -exec ls -al {} \;
There was a need to exclude not only the “_logs” directory, but also another directory located deeper in neighboring directories (for example, exclude cache in the neighboring \logs2\cache) - it’s impossible to create an OR condition in “! -regex".
Explain, please.
Answer the question
In order to leave comments, you need to log in
and what's so difficult?
Search for all images and copy them preserving the structure
Finds all images recursively from the current directory and copies them preserving the directory structure to the /tmp/backu folder
customizable
find . -regex ".*\.\(jpg\|jpeg\|gif\|png\|JPG\|JPEG\|GIF\|PNG\)" -print0 | xargs -0 cp --parents --target-directory ./tmp/backup
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question