![]() xargs takes standard input and for every N (for freebsd it is by default 5000) lines, it spawns one program with N arguments. Now, this will be slow because the rm needs to be forked and execed for each file that matches the *.jpg pattern. find /sourcedir/ -name '*.jpg' -exec cp -uf \ Īll have one program that reads the directory (the shell itself, find, and ls) and a different program that actually takes one argument per execution and iterates through the whole list of commands. Some commands, such as find and xargs, can handle large file lists without making painfully sized argument lists. This could work, but exactly how effective it would be is based on how well you can break your file list up into convenient globbable blocks. ![]() Depending on your naming convention and the number of files you actually have to process, you can run the cp command on a different subset of the directory at a time: cp -uf /sourcedir/*.jpg /targetdir/ If you're dealing with a lot of jpegs, this can become unmanageable very quick. ![]() ![]() Is essentially the same to the shell as if you wrote: cp -uf 1.jpg 2.jpg. Since the glob is processed by the shell first, and then sent to the command, the command: cp -uf *.jpg /targetdir/ There is a maximum limit to how long an argument list can be for system commands - this limit is distro-specific based on the value of MAX_ARG_PAGES when the kernel is compiled, and cannot be changed without recompiling the kernel.ĭue to the way globbing is handled by the shell, this will affect most system commands when you use the same argument ("*.jpg"). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |