On Wednesday 31 August 2005 2:16 pm, Carlos E. R. wrote:
Assume that the source directory is mounted as /usr/localfoo and the target directory is mounted on /mnt: cd /usr/local/foo find . -type f -exec cp -p {} /mnt \; This is assuming that /usr/local/foo does not have subdirectories. You can set appropriate flags in find to prevent recursion. Another possibility is to partition the output into a number of subdirectories: Assume that you may have directories: /mnt/a, /mnt/b, ... find . -name \[aA\] -exec cp -p {} /mnt/a \;
The problem is that the moment the shell tries to expand the directory listing to give it to the command line, it fails, because the commnad line becomes huge and overflows the buffer.
It is possible to work on a single file if the name is known before hand, delete, move, whatever. And perhaps on a bunch of them if the bunch is sizeable, I don't know. I'm tempted to try and create a big directory, but... :-? In the case of find, it does work on a single file. Actually, my second example has an error: find . -name \[aA\]\* -exec cp -p {} /mnt/a \; Find performs its own expansions, the shell is not involved. In the "-exec cp -p {} /mnt/a \;" The {} refers to a single file. AFAIK, find uses the dirent structure to read the directory and recurse as necessary.
--
Jerry Feldman