From owner-freebsd-questions@FreeBSD.ORG Mon Jan 2 17:24:50 2006 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 1F77816A41F for ; Mon, 2 Jan 2006 17:24:50 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from relay04.roc.ny.frontiernet.net (relay04.roc.ny.frontiernet.net [66.133.182.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id A71A743D72 for ; Mon, 2 Jan 2006 17:24:40 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from filter06.roc.ny.frontiernet.net (filter06.roc.ny.frontiernet.net [66.133.183.73]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 0811E35834F; Mon, 2 Jan 2006 17:24:40 +0000 (UTC) Received: from relay04.roc.ny.frontiernet.net ([66.133.182.167]) by filter06.roc.ny.frontiernet.net (filter06.roc.ny.frontiernet.net [66.133.183.73]) (amavisd-new, port 10024) with LMTP id 01869-04-88; Mon, 2 Jan 2006 16:51:17 +0000 (UTC) Received: from blacklamb.mykitchentable.net (67-51-143-222.dsl1.elk.ca.frontiernet.net [67.51.143.222]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 2B464358237; Mon, 2 Jan 2006 17:24:38 +0000 (UTC) Received: from [192.168.1.3] (unknown [192.168.1.3]) by blacklamb.mykitchentable.net (Postfix) with ESMTP id E12A1AE946; Mon, 2 Jan 2006 09:24:35 -0800 (PST) Message-ID: <43B961C4.8020505@mykitchentable.net> Date: Mon, 02 Jan 2006 09:24:20 -0800 From: Drew Tomlinson User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Adam Nealis References: <20060102171456.25239.qmail@web86911.mail.ukl.yahoo.com> In-Reply-To: <20060102171456.25239.qmail@web86911.mail.ukl.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-2.3.2 (20050629) at filter06.roc.ny.frontiernet.net Cc: Kevin Brunelle , freebsd-questions@freebsd.org Subject: Re: Find Syntax X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jan 2006 17:24:50 -0000 On 1/2/2006 9:14 AM Adam Nealis said the following: >--- Drew Tomlinson wrote: > > > >>On 1/2/2006 8:37 AM Kevin Brunelle said the following: >> >> >> >>>On Monday 02 January 2006 11:19, Drew Tomlinson wrote: >>> >>> >>> >>> >>>>I'm trying to find all files with a modification time older than three >>>>weeks ago. In reading the find man page and searching Google, it seems >>>>the time returned by 'ls -l' is mtime. Thus I construct the following >>>>command: >>>> >>>>find . -not \( -newermt 3w \) -exec ls -l {} \; >>>> >>>>But it returns files that are newer: >>>> >>>>-rw------- 1 nobody nobody 35292 Dec 29 08:43 totContactedRcvdPeers.rrd >>>>-rw------- 1 nobody nobody 35292 Dec 29 08:43 totContactedSentPeers.rrd >>>>-rw------- 1 nobody nobody 35292 Dec 29 08:33 >>>>./dc0/hosts/207/106/6/90/pktSent.rrd >>>> >>>>I've tried various placement of the '-not' and the )'s but I can't get >>>>it right. What am I missing? >>>> >>>> >>>> >>>> >>>Have you tried >>> >>>find . -mtime +3w >>> >>>I don't know about the other syntax but this is what I find to be the >>>simplest. >>> >>> >>> >>> >>Thanks for your reply. I tried your syntax as: >> >>find . -mtime +3w -exec ls -l {} \; >> >>It returned nothing as I expected. But then reduced it to one week as: >> >>find . -mtime +1w -exec ls -l {} \; >> >>which didn't seem to work because these (amongst many others) were returned: >> >>drwx------ 2 nobody nobody 512 Dec 27 14:03 102 >>total 2 >>drwx------ 3 nobody nobody 512 Dec 26 08:03 9 >>total 2 >>drwx------ 2 nobody nobody 512 Dec 26 08:03 7 >>total 432 >>-rw------- 1 nobody nobody 35292 Jan 2 07:41 bytesRcvd.rrd >>-rw------- 1 nobody nobody 35292 Jan 2 07:41 bytesRcvdLoc.rrd >>-rw------- 1 nobody nobody 35292 Jan 2 07:41 bytesSent.rrd >> >>Any ideas why this might be? >> >> > >if you do > >ls -l /a/directory/name > >you get directory contents. Is it possible that your "-exec ls -l {} \;" >is listing directory contents? > Yes, that's it! >To see what I mean, compare these commands: > >cd /usr/ports/arabic >find . -exec ls -l {} \;|wc > 121 991 6569 >find . -exec ls -ld {} \;|wc > 61 549 3942 >find . -ls | wc > 61 671 6617 > >If you only want files, and you really have to use -exec ls, you can do > > OK, I understand now. I ultimately want to delete files and was just trying to check my command before doing the actual delete. I will use '-ls' in my script. >find . -type f -mtime +1w -exec ls -l {} \; > > This works too. Thanks again! Drew