Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

XARGS vs -exec

Original Message
Name: Vertabreaker
Date: July 21, 2006 at 05:30:18 Pacific
Subject: XARGS vs -exec
OS: AIX
CPU/Ram: 2CPUS/4GB RAM
Model/Manufacturer: IBM
Comment:
I was just looking for a little insight on a quick clean up script I'm writing. The directory I'm cleaning up is basically temp directories that get created on almost a daily basis. Currently there are over 200 temp directories in the parent directory I'm looking to clean up.

Each of the temp directories is named via a number, ex : 1153456537603.

I want to keep a few of the most recent ones just in case they are needed but my shell script is currently this:

#!/bin/ksh
cd <parent dir>
find . -name "11*" -type d -mtime +10|xargs rm -r

The parent directory is about 120MB in size and when I tested this script with -print instead of xargs it prints out the directories I want to delete so I'm confident that this will run and work fine.

My questions are this:
1.) The script seems to take a while to execute. Is that purely due to the amount of dirs it's trying to remove?

2.) Would using -exec rm -r {} \; make it execute quicker?

3.) I put -type d in the code even though there are no files in the parent directory, is it needed? or is it redundent?

Thank in advance.

Regards
~Verta


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: July 21, 2006 at 08:20:51 Pacific
Subject: XARGS vs -exec
Reply: (edit)
1.) The script seems to take a while to execute. Is that purely due to the amount of dirs it's trying to remove?

The script is rather simple so its probably the amount of dirs.

2.) Would using -exec rm -r {} \; make it execute quicker? xargs is the preferred method. It's a lot faster than -exec. Also, with a large number of files, it's possible to overflow the command line buffer. See this link:
http://www.unixreview.com/documents/s=8274/sam0306g/0306g.htm


3.) I put -type d in the code even though there are no files in the parent directory, is it needed? or is it redundent?

If your algorithm is to only check directories I would use the type directory check.


Report Offensive Follow Up For Removal

Response Number 2
Name: Vertabreaker
Date: July 21, 2006 at 11:43:31 Pacific
Subject: XARGS vs -exec
Reply: (edit)
Nails,

Thanks for the read. It had a lot of good pointers and information. And thanks for your quick response as always :)

Regards

~Verta


Report Offensive Follow Up For Removal

Response Number 3
Name: nails
Date: July 21, 2006 at 14:29:59 Pacific
Subject: XARGS vs -exec
Reply: (edit)
You're welcome. Anytime..

Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: XARGS vs -exec

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12

help mandriva install last straw!

Icon Scaling in Explorer Bar


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC