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 <gentoo-user+bounces-125726-garchives=archives.gentoo.org@lists.gentoo.org>) id 1QicqH-0000hA-LA for garchives@archives.gentoo.org; Mon, 18 Jul 2011 01:41:54 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2E00521C2C6; Mon, 18 Jul 2011 01:41:39 +0000 (UTC) Received: from mail-ew0-f53.google.com (mail-ew0-f53.google.com [209.85.215.53]) by pigeon.gentoo.org (Postfix) with ESMTP id 48C3521C0EA for <gentoo-user@lists.gentoo.org>; Mon, 18 Jul 2011 01:40:44 +0000 (UTC) Received: by ewy8 with SMTP id 8so1501339ewy.40 for <gentoo-user@lists.gentoo.org>; Sun, 17 Jul 2011 18:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=gKt8oXmTHhfrlW1j9o+esSiAiPVNMIeou3YefghZ1fI=; b=nNqOJ8Em8OJNR39wJL/A0iN0Vu7NGG8MXnFf/EK2kvAZB3ZJROPdenymkE1DQixFWs wTJ/4NGJJrjsZ3ReKHXHMc6+zG6D9FH3Kiq+TKHflEvm7Jh8hstm5wPWS3Ylmh1oU5Pk sANo4gNs3RfcMiC77KOgEKhidrdzkLx39JkIg= Precedence: bulk List-Post: <mailto:gentoo-user@lists.gentoo.org> List-Help: <mailto:gentoo-user+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-user+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-user+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-user.gentoo.org> X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Received: by 10.14.98.207 with SMTP id v55mr1955085eef.49.1310953244396; Sun, 17 Jul 2011 18:40:44 -0700 (PDT) Received: by 10.14.50.203 with HTTP; Sun, 17 Jul 2011 18:40:44 -0700 (PDT) In-Reply-To: <1310951110.304502.9.camel@localhost.localdomain> References: <CAN0CFw2H0KVHbHtL-dzNtgi3KraB7vO+RqhYmc08w_Jv4tFWqg@mail.gmail.com> <20110717205303.6263aa02@karnak.local> <CAN0CFw1CWYSZh-_Kg4gD44OTKdOB8EAJcWNgd4DJXL_pWVzrEg@mail.gmail.com> <16810050.Acf57OJLs1@nazgul> <CAN0CFw2RX2wZQaxVmmoSShwZwdKZXDr1c-WOCsnZpJjrGzp3DA@mail.gmail.com> <1310951110.304502.9.camel@localhost.localdomain> Date: Sun, 17 Jul 2011 18:40:44 -0700 Message-ID: <CAN0CFw3RHECcBJZbOw_2fs2X0on9h5mDefLiD41c7Kr_12cP7w@mail.gmail.com> Subject: Re: [gentoo-user] Any way around "Argument list too long"? From: Grant <emailgrant@gmail.com> To: gentoo-user@lists.gentoo.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 086d7813060791684b42721ec21270b6 >> 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. =A0After a lot of > =A0^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > 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. =A0Can anyone tell me what went wrong? =A0Maybe '/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. =A0A better way > would be: > > $ man find > > Basically find works of a chain of selection criteria. =A0It crawls all > the files/dirs and when one item in the chain is true for the criteria, > it checks for the other. =A0For 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. =A0It even says in the man page: > > =A0 =A0 =A0 =A0Warnings: =A0Don't =A0forget that the find command line is= evaluated > =A0 =A0 =A0 =A0as an expression, so putting -delete first will make find = try to > =A0 =A0 =A0 =A0delete everything below the starting points you specified.= =A0When > =A0 =A0 =A0 =A0testing a find command line that you later intend =A0to = =A0use =A0with > =A0 =A0 =A0 =A0-delete, =A0you should explicitly specify -depth in order = to avoid > =A0 =A0 =A0 =A0later surprises. =A0Because -delete =A0implies =A0-depth, = =A0you =A0cannot > =A0 =A0 =A0 =A0usefully use -prune and -delete together. Alright, find is tricky. Is this the right spot for -delete? /usr/bin/find /home/user -type f -name "*-`/bin/date -d 'yesterday' +\%Y\%m\%d`*.jpg" - delete - Grant