I want it to match files and folders. However, if the folder matches the pattern, it and its contents should be moved intact. `find` handles this fine, but the `xargs` tries to execute the `mv` on the folder contents after the folder has been moved, and results in the error.
example: `find /path/to/upload` gives me the following list of items. The C64-14-AbcdE-01 folder should be moved with the html and mov files left inside. This happens just fine, but when xargs tries to mv the html file (the second line in the `find` output), it results in the 'cannot stat file' error.
/path/to/upload/C64-14-Abc
/path/to/upload/C64-14-Abc
/path/to/upload/C64-14-Abc
I've tried using the -ignore_readdir_race option, which should help with this issue (`man` contents for this `find` option below), but it does not change anything. I believe this is because I'm piping the output through two additional commands, and there's no actual race condition in the `find` execution. This is why I'm trying to combine my find, grep and mv into a single find execution.
`man` contents for -ignore_readdir_race option for `find`:
-ignore_readdir_race
Normally, find will emit an error message when it fails to stat a file. If you give this option and a file is deleted between the time find reads the name of the file from the directory and the time it tries to stat the file, no error message will be issued. This also applies to files or directories whose names are given on the command line. This option takes effect at the time the command line is read, which means that you cannot search one part of the filesystem with this option on and part of it with this option off (if you need to do that, you will need to issue two find commands instead, one with the option and one without it).
Main Topics
Browse All Topics





by: TintinPosted on 2009-09-13 at 18:44:19ID: 25322591
Just add a
-type f
to the find command to have it only match files.