[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: general linux questions



On Fri, Oct 06, 2000 at 04:13:27PM +0200, robert_wilhelm_land wrote:
> will trillich wrote:
> > i keep forgetting about xargs. very clever gizmo!
> > 
> > to sort the output by date, it's rather simple:
> > 
> >     locate <path-match-string> | xargs ls -dlt
> > 
> > the -d is so directoriy contents wouldn't be listed, only the directory
> > item itself; -l says 'gimme a long listing' and -t says 'sort by modified
> > time'...
> 
> 
> I'm so unsure about the xargs and the exec command. Which one is
> prefered, in which cases should I use one of the two?
> 
> Thanks for the command string!

no charge for services rendered...

	$ find /path/to/start/in -mtime +7 -exec /bin/ls \{} \;

this will execute "/bin/ls <filepath>" for EACH AND EVERY file it finds.
not a problem if you have a quickie subprocess to spawn and respawn.

if you're launching, say, perl, even to run some quickie gadget, reconsider:
perl is frivolous with resources. every startup basically requires blessings
from the pope. nearly.

ANY resource hog is something to launch seldom -- and when it's
up, make it earn its keep.

	$ locate some/path/component | xargs behemoth -options

this will accumulate a slew of filepaths to send to xargs; xargs then
will exec 'behemoth' ONCE with the options you supply it, appending
all the filenames to the end of the list.

of course, there's a limit to what you can get away with here; the command
buffer is only so large (i doubt there's facility to accomodate 10k of
arguments for a command -- surely there's someone here who knows the limit
or how to find it). so sometimes you hafta break your find down
into subtasks, or specify more specific items to look for (so you
get less items returned).

--

note -- if you have the locate command available, use it instead of
find when you're looking for a filename pattern system-wide. then you
have a simple linear scan of one file instead of a disk-intensive
manhunt. (with locate you also ought to have 'updatedb' run occasionally
via cron. also, use slocate, which is more security-conscious.)

-- 
things are more like they used to be than they are now.

will@serensoft.com *** http://www.dontUthink.com/



Reply to: