I use find
command to find all regular files older than some number of minutes in a directory tree containing some symbolic links that need to be resolved:
find -L . -type f -mmin +300 -print
But this directory tree has some looped symbolic links that cause find
to emit errors like:
/usr/bin/find: File system loop detected; ‘/storage/tester1/data/webdav’ is part of the same file system loop as ‘/storage/tester1/data’
I can't remove this loops from directory structure and can't avoid using key -L
but I need to suppress this errors to get right exit code from find
to detect any real possible errors (and not 'loop detected' warnings).
Redirecting of sdterr 2>/dev/null
can't help because I still get exit status 1 on any search because of this loops, and it makes impossible to detect presence or absence of any real errors during searching in my script.
How can I avoid it and get exit status 0 on successful search in directory tree that has symlink loops?
Note: I know that there are some similar questions about 'loop detected' on this site, but all these questions could be solved by removing following of symbolic links (that is impossible in my case), so this question is not a duplicate. Please, don't close it!
find -H . ./foo/good_link_1 ./bar/baz/good_link_2 …
./
. Maybe it's easier to assume such symlink exists and start from/
in the first place, without-L
. What bad will happen if this assumption is wrong? A user may create such symlink anytime just for fun… Right? What difference does it make if the link is really there? Please make sure there is no XY problem here. Edit the question if there is.