I have a very specific need to search for files and directories in Solaris using a script and should be able to exclude all directory paths from the path, since they contain potentially thousands of files that were not saved (and this is normal, because they are files hosted on other servers). I donβt even want to find a search in these directories, because it will hang on the server (cpu spiking up to 99% for a long time), so displaying search results in egrep to filter these directories is not an option.
I know I can do this to exclude one of the following directories by name:
find / -mount -local \( -type d -a \( -name dir1 -o -name dir2 -o dir3 \) \) -prune -o \( -nouser -o -nogroup \) -print
However, this will match dir1 and dir2 in any directory structure of any directories, which is not what I want at all.
I want to prevent searches from searching the following directories (as an example):
/opt/dir1 /opt/dir2 /var/dir3/dir4
And I still want it to detect files and directories not registered in the following directories:
/opt/somedir/dir1 /var/dir2 /home/user1/dir1
I tried using regex in the -name arguments, but since I only find the match "name" with the base name of what it finds, I cannot specify the path. Unfortunately, Solaris find does not support GNU search options like -wholename or -path, so I'm a little screwed up.
My goal would be to have a script with the following syntax:
script.sh "/path/to/dir1,/path/to/dir2,/path/to/dir3"
How can I do this using search and the standard sh script (/ bin / sh) in Solaris (5.8 and above)?