OS: openSUSE 11.2
As you can see from the script below this find command with sudo in front of it won't work when in a subdir of the root user. The line itself is inside a shell script (run as root user) however the result is the same whether on the command line or in the script file.
The error seems self-explanatory to me, that is, it can't "stat" the current directory. I assume "stat" means read the attributes or something similar about the directory, which makes sense. However, as you can see from the line there is no reason for it to read the current directory as it's being directed to read an entirely different directory.
My first question is, is this normal or is this a bug? To me it looks like a bug but could just be something required because of security issues of some sort.
My second question is, if it is not a bug, is their some sort of cool command line switch to make the error go away or is just "cd'ing" first to the directory I'm going to do the find on the best approach?
neutrino:/data/archive # sudo -u reg find "/data/archive/" -maxdepth 1 -type f
neutrino:/data/archive # cd ~/scripts/drupal/
(we are root user)
neutrino:~/scripts/drupal # sudo -u reg find "/data/archive/" -maxdepth 1 -type f
find: cannot stat current directory: Permission denied