In my previous question In find -exec, how to substitue current file by {}?, I have asked about test with find
.
I want to find all files I do not own.
So there is proper find command:
find . -type f ! -user "$USER"
but so should be this one as well:
find . -type f -exec bash -c '
for pathname do
[[ ! -O "$pathname" ]] && printf "%s\n" "$pathname"
done' bash {} +
yet both gives different results .
1) if I do [command one] | wc -c
--> 4121
But: [command two] | wc -c
--> 236768
(PS: I am searching files in my $HOME).
Both gives different numbers of how many files they found.
2) Both still give in result files, that are directories (yes, directories I do not own and thus - permission denied). They give directories despite having find . -type f
type files (not dirs) in argument of option, why? (When I ls -ld
one of those directory, none is link or anything else)
sudo
? You would definitely get "Permission denied" errors whenfind
tries to enter directories not owned by you that you don't have access to. This is most likely why these errors occur. Have you looked at the output (not errors) to try to figure out what the differences in result are?wc
(or I only see it afterwc
, but the error could arise before pipe byfind
) 2) No I did not look at results, there is many files, that would take a lot of time to compare, neither doesdiff
work, because that would be the other way - big output. Is there any program for that? Anyway, why it is showing directories, when specifiedtype f
?find
results mention directories. If you have directories that you don't have access to, I would expect these to show up in error messages. As for comparing, just sort the output and usediff
.find
is trying to explore that directory to find files, and getting that error as a result. As for the differences in files listed: rather than trying to catalog them all, I'd just look at the first few differences, and try to figure out why they're different.wc -c
? That will count characters, not lines. So it doesn't help you know how many results you got, only how those results were reported. I doubt this is the issue, it just seems strange to use-c
here.