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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am using find command to search f

Status
Not open for further replies.

nwo4life

Technical User
May 16, 2002
23
0
0
US
I am using find command to search for files older then 2 days in a directory and delete the files.
The directory structure is like this - /home/test and /home/test/nwo.
There are files that are older then 2 days in both /home/test and /home/test/nwo directory.
I want to delete the files out of /home/test & not delete files from /home/test/nwo directory.

Thanks in advance.
 
Hi nw0life

You can use find command with following syntax:

#find /home/test -name 'file*' -mtime +2 -exec rm {} \;

Please Be careful while typing for this syntax

That's it!

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Hi nwo4life,

The following should do what you want ;

find /home/test -name nwo -prune -o -ctime +2 -exec rm {}

This excludes the "nwo" directory under /home/test.

GM
 
What if there is more then just the nwo directory, like a home/test/nwo1,home/test/nwo2,home/test/nwo3 etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top