How to make 'find' not search the Windows partition?
Posted: Mon 22 Apr 2013, 13:16
I am running slacko5.5 installed as a full install. My Windows partition is /mnt/sda3. I was trying to tailor a 'find' to search only the linux part of the file space. I know I can do that by unmounting sda3, but that is inconvenient very often. In constructing the 'find' it seemed to me that either one of 2 expressions ought to do the job: ' ... ! -name "/mnt/sda3* ..." or '... path "/mnt/sda3" -prune", but the one with -prune ought to run a whole lot faster. The full command line would look something like:
a. find / \( -name "xxx...xxx" -a ! -name "/mnt*" \) ..., or
b. find / \( -name "xxx...xxx" -a -prune "/mnt*" \) ... or
c. find / \( -path "/mnt*" -prune -a -name "xxx...xxx" \) ... or
d. find / \( -name "/mnt*" -a -name "xxx...xxx" \) or
e. find / \( ! -name "/mnt*" -o -name "xxx...xxx" \) or
f. find / -path "/mnt" -prune -o -name "xxx...xxx' ...
The results are:
a, b, c, d all include many files starting "/mnt...".
e did not try
f works properly
It seems to mean that, in general, one must know enough about the expression to be searched upon to know where in the path it occurs. Its as if one gets only one crack at the path of each file, despite the syntax, so one must sort ones expressions. If you have 2 search strings, A and B, both of which must be present, but in any sequence, you mist try them as '-name a -a -name B' and also as '-name B -a -name A' to make sure you haven't got past either one, which ,makes no sense. Yes, you could shorten it to '\( -name "*A*B" -o -name "*B*A" \)'. Does this make sense? I believe that expectation is flawed. What does anyone else think?
a. find / \( -name "xxx...xxx" -a ! -name "/mnt*" \) ..., or
b. find / \( -name "xxx...xxx" -a -prune "/mnt*" \) ... or
c. find / \( -path "/mnt*" -prune -a -name "xxx...xxx" \) ... or
d. find / \( -name "/mnt*" -a -name "xxx...xxx" \) or
e. find / \( ! -name "/mnt*" -o -name "xxx...xxx" \) or
f. find / -path "/mnt" -prune -o -name "xxx...xxx' ...
The results are:
a, b, c, d all include many files starting "/mnt...".
e did not try
f works properly
It seems to mean that, in general, one must know enough about the expression to be searched upon to know where in the path it occurs. Its as if one gets only one crack at the path of each file, despite the syntax, so one must sort ones expressions. If you have 2 search strings, A and B, both of which must be present, but in any sequence, you mist try them as '-name a -a -name B' and also as '-name B -a -name A' to make sure you haven't got past either one, which ,makes no sense. Yes, you could shorten it to '\( -name "*A*B" -o -name "*B*A" \)'. Does this make sense? I believe that expectation is flawed. What does anyone else think?