M
M
MonsterMan2017-04-04 12:01:09
linux
MonsterMan, 2017-04-04 12:01:09

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

1 answer(s)
V
Victor Taran, 2017-04-04
@MonsterMan

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 question

Ask a Question

731 491 924 answers to any question