At Sat, 23 Jan 2010 12:43:40 +0000 CentOS mailing list <centos@xxxxxxxxxx> wrote: > > Robert Heller wrote: > > At Sat, 23 Jan 2010 15:23:58 +0300 CentOS mailing list <centos@xxxxxxxxxx> wrote: > > > >> Content-Language: en-us > >> > >> > >> The directory that I am trying to clean up is huge . every time get this > >> error msg > >> > >> > >> > >> -bash: /usr/bin/find: Argument list too long > > > > 'man xargs' > > > > find <mumble> -print | xargs rm > > > Hi > > Just curious. What is the difference between the command above and "find > <numble> -exec rm -f {} \;" ? The command "find <mumble> -exec rm -f {} \;" collects ALL of the names "find <numble>" as a single command line, which in your case is too large for the shell to deal with. The command "find <mumble> -print | xargs rm" uses a pipeline. "find <mumble> -print", *prints* the names it finds to stdout. xargs reads stdin, line by line, and collects those lines as words up to some reasonable string length (within the shell's command line length limits) and passes this argument list to xargs's arguments. If necessary, xargs will call the command repeatedly with suitable subsets of the complete list, keeping each subset below the shell's command line string length limit. The '-exec ...' option to find is fine for small sets of results. The "find ... -print | xargs ..." will handle arbitrarily large result sets. xargs can also be used anyplace you happen to have a list of names (one per line) that you need to pass as words to a command: tar tzf foo.tar.gz| xargs -r ls -d Will list those files that are in the tar file that are also on disk. The '-r' option to xargs will prevent xargs from calling ls with no arguments, if xargs happens not to get any input. > > Thanks > > mg. > > _______________________________________________ > CentOS mailing list > CentOS@xxxxxxxxxx > http://lists.centos.org/mailman/listinfo/centos > > -- Robert Heller -- 978-544-6933 Deepwoods Software -- Download the Model Railroad System http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows heller@xxxxxxxxxxxx -- http://www.deepsoft.com/ModelRailroadSystem/ _______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos