Date: Mon, 5 Dec 2005 15:10:09 -0800 From: Bill Campbell <freebsd@celestial.com> To: freebsd-questions@freebsd.org Subject: Re: cp/mv/etc : argument list too long ... I am sick of this Message-ID: <20051205231009.GB74432@alexis.mi.celestial.com> In-Reply-To: <Pine.LNX.4.21.0512051747390.8684-100000@shell.dhp.com> References: <Pine.LNX.4.21.0512051747390.8684-100000@shell.dhp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Dec 05, 2005, user wrote: > >Ok, so I have some big directories with lots of files. If I do mv or cp, >it always refuses, telling me: > >cp: argument list too long > >so, no problem ... I get creative with things like this: > >for f in 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W >X Y Z ; do cp $f* /some/dir ; done > >lame, but it works. man xargs Copying individual files isn't an ideal application for xargs since it breaks its standard input into arguments, but it works great for many things. Find all files containing some pattern one might use: find . -type f print | xargs grep -l pattern If files may contain funny characters (e.g. whitespace) find . -type f -print0 | xargs -0 grep -l pattern The example above copying files is probably best handled with cpio or tar: find . -print | cpio -pdumv destdir Disclaimer: I'm accustomed to the gnu-ish behaviour of these tools, and FreeBSD routines may differ. Bill -- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software LLC UUCP: camco!bill PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 URL: http://www.celestial.com/ ``If we got one-tenth of what was promised to us in these acceptance speeches there wouldn't be any inducement to go to heaven.'' Will Rogers
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051205231009.GB74432>