From owner-freebsd-questions@FreeBSD.ORG Mon Dec 5 23:10:11 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A63016A41F for ; Mon, 5 Dec 2005 23:10:11 +0000 (GMT) (envelope-from bill@celestial.com) Received: from mail.mi.celestial.com (dagney.celestial.com [192.136.111.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id CBF5B43D64 for ; Mon, 5 Dec 2005 23:10:10 +0000 (GMT) (envelope-from bill@celestial.com) Received: from localhost (localhost [127.0.0.1]) by mail.mi.celestial.com (Postfix) with ESMTP id 5B9B51B477; Mon, 5 Dec 2005 15:10:10 -0800 (PST) Received: from mail.mi.celestial.com ([127.0.0.1]) by localhost (alexis.mi.celestial.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 77507-01; Mon, 5 Dec 2005 15:10:10 -0800 (PST) Received: by mail.mi.celestial.com (Postfix, from userid 203) id F09071B3FA; Mon, 5 Dec 2005 15:10:09 -0800 (PST) Date: Mon, 5 Dec 2005 15:10:09 -0800 From: Bill Campbell To: freebsd-questions@freebsd.org Message-ID: <20051205231009.GB74432@alexis.mi.celestial.com> Mail-Followup-To: freebsd-questions@freebsd.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: amavisd-new at mi.celestial.com Subject: Re: cp/mv/etc : argument list too long ... I am sick of this X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@celestial.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Dec 2005 23:10:11 -0000 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