From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QicHt-00055i-Aa for garchives@archives.gentoo.org; Mon, 18 Jul 2011 01:06:23 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 80F2021C25D; Mon, 18 Jul 2011 01:06:07 +0000 (UTC) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by pigeon.gentoo.org (Postfix) with ESMTP id 3E1E321C0E4 for ; Mon, 18 Jul 2011 01:05:11 +0000 (UTC) Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id E240D20ECD for ; Sun, 17 Jul 2011 21:05:10 -0400 (EDT) Received: from frontend2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Sun, 17 Jul 2011 21:05:10 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=subject:from:to:date:in-reply-to:references:content-type:content-transfer-encoding:message-id:mime-version; s=smtpout; bh=CeGTBwPg9k/kOUuNYOStV/x3qIs=; b=djXkpAMT7IU+SSPN/0MRi/Wn+41bIRi/hBAdCz8YEzjXzoVeN6vKdTTOxg210yhM4AcyYpGVs4ZHGK4QAh9k61csddRvBO8VU15lcfCTWaYa0FT/u4PZtcteZR92IXNGHHiXoh8OZdPkexAEaNEvlEgQJF8URwqL6BPcftTtH54= X-Sasl-enc: HFg1Mtd01Z6D9Y8dUrN5IFvLBzFHc18dvSz1l9SfMkwH 1310951110 Received: from [192.168.31.28] (cpe-174-109-037-078.nc.res.rr.com [174.109.37.78]) by www.fastmail.fm (Postfix) with ESMTPSA id 965CD4409FD for ; Sun, 17 Jul 2011 21:05:10 -0400 (EDT) Subject: Re: [gentoo-user] Any way around "Argument list too long"? From: Albert Hopkins To: gentoo-user@lists.gentoo.org Date: Sun, 17 Jul 2011 21:05:10 -0400 In-Reply-To: References: <20110717205303.6263aa02@karnak.local> <16810050.Acf57OJLs1@nazgul> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAADBQTFRF1///CwsLGxsbJycnNzc3RUVFU1NTYmJicXFxf39/jIyMm5ubq6urubm5yMjI3t7eukg4JQAAAAF0Uk5TAEDm2GYAAAIoSURBVDhPpZC9btRQEEbPGIJQhOIZB4SEhGJ7W/42lihoKCJ6agoeglfgDXiQPAGEio5sKGgTLxRIFNk7DigV7FD4J4SW23jud+75ZA38x9ncnb3wf0PgjZnZdvo35rVZZWa3RiLDd+PGMNz5oABkw/2e9ne+HTgwGRt3nejHzc8Gk/EURfvx/IgLcK3YNZWB7C8vwFqtqcxEAPYD4CoAr5xUiBaJlfOrvTA+IRLqLhisWx/B9RItzckjHCJNxtqKGhRBgEiTAWCIBqGXDNBODEdBIWIEgquCiosD6GQsTYzAVVUAH0FCFDPP3ce8Byenx0hhFRBoX5cBFPXJUVILUog6rTOs5Mv5DnGyOAaXHMvb0fiU3z8QbNZAjmg5VXVbP/N0uHhyWJrAl8RYhebzVcq+K4CJ2WgomSbWsSsguRY6GtncD0N0EYImEcrRkPUxXcrKflNYN4LUmqKndQVOV5qOIDp5Vhb518oEqqxgBFuyOhSKlRF4NptPhp22Ee0ylnioNfVkPPLSix1SG9BJrRN4aFcevfNIKw8f8h5k8vtsnlUauSBiF2DD6/ePd5LPAOvzHpw97F6+dbHOk1T1X4DnXN2rlF+OWKXAuN3Cj3HHNW5u/13FzeQtEkv/YU0vDCATjZSn8KqZXwLdA3Kny+q6GZoGwPPFmZ5oNWt29TK4/XSVpK6bPRny4a+Qx1+FrNkrdATji/XHhdTbw55gMrC0TaFTEfwB/cbNxoZIacsAAAAASUVORK5CYII= Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.0.2 Content-Transfer-Encoding: 7bit Message-ID: <1310951110.304502.9.camel@localhost.localdomain> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org Mime-Version: 1.0 X-Archives-Salt: X-Archives-Hash: 1cda2edc90ba40135082f945e3993159 On Sunday, July 17 at 17:47 (-0700), Grant said: > ran this and the output was voluminous but looked good: > > /usr/bin/find /home/user -type f -name "*-`/bin/date -d 'yesterday' > +\%Y\%m\%d`*.jpg" > > So I ran it again, adding -delete right before -type. After a lot of ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ That was a mistake. > processing I got a line of output like this for each file: > > /usr/bin/find: `/home/user/1-2011071612345.jpg': No such file or > directory > > Unfortunately the command actually deleted the entire /home/user > folder. Can anyone tell me what went wrong? Maybe '/home/user' was > at the very top of the long list that scrolled up the screen when I > ran the find command without -delete? > Well this is an unfortunate way to learn how find works. A better way would be: $ man find Basically find works of a chain of selection criteria. It crawls all the files/dirs and when one item in the chain is true for the criteria, it checks for the other. For example $ find /path -type f -name blah -print Crawls /path, for each file/dir it checks if it is a regular file (-type f), if that is true, it checks if it's name is "blah", if that is true, it prints the name (blah). Therefore, $ find /path -delete -type f -name .... Crawls path, then checks "-delete".. but wait, -delete evaluates to "true if removal succeeded" (find(1)), so it deletes the file, then checks to see if it is a regular file, then if that is true then it checks the name... but all that doesn't matter because your files are deleted. You should never put -delete at the beginning of a chain and, arguably, you shouldn't use -delete at all. It even says in the man page: Warnings: Don't forget that the find command line is evaluated as an expression, so putting -delete first will make find try to delete everything below the starting points you specified. When testing a find command line that you later intend to use with -delete, you should explicitly specify -depth in order to avoid later surprises. Because -delete implies -depth, you cannot usefully use -prune and -delete together.