A
A
Anatoly2019-01-16 15:54:55
bash
Anatoly, 2019-01-16 15:54:55

How to find a file with the find command?

The task is this, there are many files and many directories modified:
/var/www/.../2019/modified/pict1_800x600.jpg
/var/www/.../2019/modified/pict1_1024x768.jpg
'...' - it is indicated for a reason, the path is not known
, these files must be deleted if there is no pict1_parent.jpg file in the /var/www/.../2019/ folder, the
task must be solved with Debian and bash utilities

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
q2zoff, 2019-01-16
@Tolly

find /var/www -type f -regex ".*/modified/[^/]+\.jpg" | while read -r path; do name="${path##*/}"; [ ! -f "${path%modified/*}${name%%_*}_parent.jpg" ] && rm -f "$path"; done

V
vreitech, 2019-01-16
@fzfx

for i in $(find /var/www -name "modified" -type d); do if ; then rm -rf "$i"/pict1_*.jpg; fi; done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question