Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Mar 2007 14:40:50 -0800
From:      Gary Kline <kline@tao.thought.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: find returns unusable result
Message-ID:  <20070302224050.GB99502@thought.org>
In-Reply-To: <20070228233824.GA25235@ayn.mi.celestial.com>
References:  <D29D90080F802A4D1BBB3EDE@utd59514.utdallas.edu> <20070228231635.GB73748@just.puresimplicity.net> <45E6113A.2060500@unsane.co.uk> <20070228233824.GA25235@ayn.mi.celestial.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 28, 2007 at 03:38:24PM -0800, Bill Campbell wrote:
> 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.


	I don't mean to steal this thread, but it might help to know if
	egrep -[xyz] bar or other things might be joined in the " | xargs"
	part of the pipeline.  Lots of times I'll want a find search to 
	print0 filename and egrep, say, -3 strings and search for
	substrings nearby.  The greps will recurse across many dirs with
	scores of files so I want to search to be efficient.  In other 
	words, how flexible is xargs?

	gary





> 
> 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''
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"

-- 
  Gary Kline  kline@thought.org   www.thought.org  Public Service Unix




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070302224050.GB99502>