From owner-freebsd-questions@FreeBSD.ORG Fri Mar 2 17:57:10 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DC81F16A401 for ; Fri, 2 Mar 2007 17:57:10 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from ayn.mi.celestial.com (hayek.celestial.com [192.136.111.12]) by mx1.freebsd.org (Postfix) with ESMTP id BE92413C481 for ; Fri, 2 Mar 2007 17:57:10 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from localhost (localhost [127.0.0.1]) by ayn.mi.celestial.com (Postfix) with ESMTP id 0858F6860B93C; Wed, 28 Feb 2007 15:38:25 -0800 (PST) X-Virus-Scanned: amavisd-new at mi.celestial.com Received: from ayn.mi.celestial.com ([127.0.0.1]) by localhost (ayn.mi.celestial.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Ev5ZyiXzQbFe; Wed, 28 Feb 2007 15:38:24 -0800 (PST) Received: by ayn.mi.celestial.com (Postfix, from userid 203) id DF5E36860B93B; Wed, 28 Feb 2007 15:38:24 -0800 (PST) Date: Wed, 28 Feb 2007 15:38:24 -0800 From: Bill Campbell To: freebsd-questions@freebsd.org Message-ID: <20070228233824.GA25235@ayn.mi.celestial.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <20070228231635.GB73748@just.puresimplicity.net> <45E6113A.2060500@unsane.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45E6113A.2060500@unsane.co.uk> User-Agent: Mutt/1.5.11 OpenPKG/2.5 Subject: Re: find returns unusable result 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: Fri, 02 Mar 2007 17:57:10 -0000 On Wed, Feb 28, 2007, Vince wrote: >Josh Tolbert wrote: >> On Wed, Feb 28, 2007 at 05:12:58PM -0600, Paul Schmehl wrote: >>> I'd like to cron a process that looks at a certain folder every day and >>> changes the perms on a directory if they aren't what I want. >>> Unfortunately, the people creating the folders are Windows folks using >>> WinSCP, and so they create folders with spaces in them. (E.g. Day 1, Day >>> 2, etc.) >>> >>> I thought I could just do this: >>> chmod 755 `find /path/to/dirs -type d` >>> >>> but find returns a directory name of Day, Day, Day, which (obviously) >>> doesn't work. >>> >>> >From the cli, find returns the actual directory name. >>> >>> How can I get find to return the dirs correctly in a script? Or is there >>> some other way to do this that would work? >>> >>> Paul Schmehl (pauls@utdallas.edu) >> >> find /path/to/dirs -type d -print0 | xargs -0 chmod 755 >> >or just >find /path/to/dirs -type d -exec chmod 755 {} \; >should do it. While that works, the -print0 | xargs -0 is far more efficient as it isn't exec'ing a process for every match. This may not be important for a few files or directories, but can make a significant difference when processing thousands of entries. Bill -- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 When I hear a man applauded by the mob I always feel a pang of pity for him. All he has to do to be hissed is to live long enough. -- H.L. Mencken, ``Minority Report''