URL: <https://savannah.gnu.org/bugs/?67330>
Summary: -exec[dir] has odd behavior when there are a lot of
files
Group: findutils
Submitter: None
Submitted: Wed 16 Jul 2025 07:34:24 PM UTC
Category: find
Severity: 3 - Normal
Item Group: Wrong result
Status: None
Privacy: Public
Assigned to: None
Originator Name: Sky
Originator Email: [email protected]
Open/Closed: Open
Discussion Lock: Any
Release: 4.10.0
Fixed Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Wed 16 Jul 2025 07:34:24 PM UTC By: Anonymous
Description
###########
I did some benchmarking with the 'find' command using the '-exec' and
'-execdir' options and came across odd behavior when using 'mv' as the command
to run after 'find' got all the files.
I wanted to see which version of a command would run faster:
- time find -name 'file*' -exec mv -t a '{}' +
or
- time find -name 'file*' -execdir mv -t ../a '{}' +
Setup
#####
1) Make a new directory to do our testing and 'cd' into it (the name doesn't
matter).
user $ mkdir test
user $ cd test
2) Make two new directories called "a" and "b".
user $ mkdir a b
3) Make 100,000 files in directory "a".
user $ touch a/file{1..100000}
4) Run the following command to move all the files in "a" to "b":
user $ find -name 'file*' -exec mv -t b '{}' +
The 'find' command *does* move all the files to directory "b", but 'mv' prints
the following:
mv: './b/file1' and 'b/file1' are the same file
mv: './b/file2' and 'b/file2' are the same file
mv: './b/file3' and 'b/file3' are the same file
...
mv: './b/file100000' and 'b/file100000' are the same file
Upon checking "b", all the files are there and "a" has no files (this is
expected), but when we run 'find' to move the files from "b" to "a", there are
no messages.
The command
user $ find -name 'file*' -exec mv -t a '{}' +
will not print any messages and still move the files. I tested this with the
'-execdir' option as well, and still got this odd behavior.
Trying this with version 4.8.0 results in the reverse being true--where trying
to move files to "a" prints messages from 'mv'. Another thing to note is that
this only happens when there are a LOT of files; if there are only three
files, this odd behavior doesn't happen.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?67330>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
