Wednesday, March 28, 2012

mtime or find old files or delete old files

If you want to find old files, i.e. find files greater that 30 days using following command

Find and Print Files:-
find -type f -name <'Search pattern*'> -mtime +30 -print

Delete files greater than 30 days:-(Time is important in this)
find /cba_app/WSSORD01/DEV/archive/outbound -name DLMASY* -mtime +30 -exec rm {} \;

Good site for reference
http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html

Create Files as backdated files

If you want to create files in UNIX as backdated files, i.e. file creation date as old dates, follow below steps or commands.

Syntax:-
touch
This will create a file of that specific Month, Date for that year.

Example:-
touch 03302200 SAMPLE_20120330000000.txt;