Finding Files in IBM AIX

Posted: September 14, 2012 in HowTo
Tags: , ,

General syntax of “find” command

$ find <where> <condition> <action>

To get all files/directories in the current and sub directories

$ find .

To get all files/directories in the current and sub directories that were modified 5 (5*24 hours, to be precise) or fewer days ago

$ find . -mtime -5

To get all files/directories in the current and sub directories that were modified 10 or more days ago

$ find . -mtime +10

To get all files/directories in the current and sub directories that were modified exactly 15 days ago

$ find . -mtime 15

To delete all files/directories in the current and sub directories that were modified 30 or more days ago

$ find . -mtime 30 -exec rm -r {} \;

To delete all files in the current and sub directories that were modified 30 or more days ago

$ find . -mtime 30 -type f -exec rm -r {} \;

To delete all files with extension ‘log’ in the current and sub directories that were modified 30 or more days ago

$ find *.log -mtime 30 -type f -exec rm -r {} \;

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s