The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 Batch commands
Author: k 
Date:   30-01-03 18:03

To speed up commands try batching them.
Instead of the following to delete files older than 30 days in a
script:

#!/usr/local/bin/ksh
find /mypath -type f -mtime +30 -exec rm {} \;
exit $?

Try using a "+" instead of the usual "\;"

Such as:
find /mypath -type f -mtime +30 -exec rm {} +

Reply To This Message
 
 Re: Batch commands
Author: Dan Langille 
Date:   31-01-03 02:53

Thanks. Why will that speed it up?

Reply To This Message
 
 Re: Batch commands
Author: k 
Date:   31-01-03 04:46

Hmmm..apparently this works on certain versions of "find". It works on Solaris, but isn't documented...but doesn't seem to work on
my version of "find" on 4.7 STABLE. But is in the draft of POSIX.1
I'll have to try this on different boxen and see what happens.

Reply To This Message
 
 Re: Batch commands
Author: k 
Date:   02-02-03 18:09

Dan Langille wrote:
>
> Thanks. Why will that speed it up?

Apparently some (all? ..not sure) SysV versions of find will
execute a single command and pass to it the file name arguments rather than executing the command for each file name found.

So a command of:
find . -exec chmod u+w {} +
will execute a single chmod command and pass to it the arguments
rather than doing a chmod for each filename.

I didn't know at the time I posted that it doesn't work on FBSD
but if anyone finds themselves at a SysV system, they may want to try it out.

Reply To This Message
 
 Re: Batch commands
Author: Rob Robinson 
Date:   10-02-04 17:25


find . -name zot6 -exec chmod u+w {} \;

The above command worked for me in the bash shell of a
freeBSD system. I added the "-name zot6" part to make sure that the exec only modified the file that matched the search criteria.

We are using bash version 2.05a and freeBSD version 4.6

Reply To This Message
 
 Re: Batch commands
Author: satimis 
Date:   04-06-04 03:26

Hi folks,

FreeBSD 5.2.

Dose ksh refer to Korn Shell (ksh)?

If YES, I could not locate CDE (Graphics and ksh) nor dtksh nor on my PC nor on /usr/ports/

# cd /usr/ports
# make search -i name=dtksh
# make search -i name=CDE

Kindly advise. TIA

B.R.
satimis

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org