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

Re: [K12OSN] Way OT: scripting help

On Thursday 24 May 2007 3:16 pm, Les Mikesell wrote:
> Dan Young wrote:
> > Dimitri Yioulos wrote:
> >> I'm still grateful, but that construct didn't work upon test.  The error
> >> msg is "Usage: find [path...] [expression]".  I tried putting the new
> >> code in various places in my original line, but no joy.  Any idea why
> >> I'm getting the error?
> >
> > I added a backslash to escape the newline so it would wrap in my mail.
> > Can you try putting the whole thing on one line? I shorted some names to
> > make it fit here:
> >
> > find $WORK -maxdepth 1 -mtime +$DAYS ! -name file -exec rm {} \;
> >
> > And test with non-critical data, of course.
> I always do it this way:
> find ..options... -print0 |xargs -0 command
> This way find writes the list of files to stdout, xargs reads them and
> collates into reasonable sized groups and puts them on the command line
> of the specified command.  It's more efficient than exec'ing the command
> for each file and you don't have to worry about the command line size
> limit like you might for a wildcard expansion or
> command `find ...options...`
> The print0 and -0 xargs option specify that the names will be null
> terminated so embedded newlines in filenames don't confuse things.
> find $WORK -maxdepth 1 -mtime +$DAYS ! -name file -print0 |xargs -0 rm
> You can leave off the -print0 and xargs part to preview the list or
> redirect it to a file if you want to check it first.
> --
>    Les Mikesell
>     les futuresource com
> _______________________________________________
> K12OSN mailing list
> K12OSN redhat com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>

Thank you all very much.  These pointers have solved my problem and taught me 
a lot.  I'm most grateful.  This is a great list.


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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