Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help removing files

Status
Not open for further replies.

buzzcasper

Technical User
Jan 14, 2003
7
US
Here's the code I'm currently using:

"find /tmp -name "pri*_dumptrace*" -mtime +7 -exec rm {} \;
-print"

I want to know if there's a way I can stop this command from going into the subdirectories of the /tmp directory that I don't have access to get into (the command tries to get in the subdirectories spitting errors out to me); I could send the error messages to /dev/null but I want to see if there's a better solution.

Brett

 
From the man pages:

-prune Always evaluates to the value True. Stops the descent of the current pathname if it is a directory. If the -depth flag is specified, the -prune flag is
ignored.

So this should work:

"find /tmp -name "pri*_dumptrace*" -prune -mtime +7 -exec rm {} \;




IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
The command "find /tmp -name "pri*_dumptrace*" -prune -mtime +7 -exec rm {} \;" didn't seem to work; the search still descended into the subdirectories giving me permission errors for the subdirectories I shouldn't be able to get into.
 
Hi buzz
The find command does recursive search in directory tree.
Your wish will not be fullfilled with this command..
Let us think for someother utility...

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
If you just want to check and delete files other than directories within /tmp, this may do what you want.

ls -l /tmp |awk '! /^d/ {print $NF}'|xargs -l -i find /tmp/{} -mtime +7 -exec rm {} \;


Dave
 
The prune needs to be evaluated first. The following skips the subdirectories before processing the files:

find /tmp \( -type d ! -name 'tmp' -prune \) -o \( -name "pri*_dumptrace*" -mtime +7 -ls \) -exec rm {} \;

Cheers,
DC
 
Hm why not just find without added maches? Isnt the "-o" for additional matches, I think he wanted just this
find /tmp -type f -name "pre*_dumptrace*" -mtime +7 -exec rm {} \;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top