====== Find ======
To find all files that was modified since a specific time ago\\
(i.e an hour ago, a day ago, 24 hours ago, a weeks ago and so on) in Unix environment,\\
the find command will come in handy. The command syntax is:
To find all files modified in the last 24 hours (last full day) in current directory and its sub-directories:
find . -mtime -1 -print
Flag -mtime -1 option tells find command to look for files modified in the last day (24 hours).\\
Flag -print option will cause find command to print the files’ location.\\
-print can be replaced with -ls if you want a directory-listing-type response.
To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:
find /directory_path -mtime -1 -print
The command is basically the same with the earlier command,\\
just that now you no need to cd (change directory) to the directory you want to search.
To find all files with regular file types only,\\
and modified in the last 24 hours (last full day) in current directory and its sub-directories:
find /directory_path -type f -mtime -1 -print
To find all files that are modified today only (since start of day only, i.e. 12 am),\\
in current directory and its sub-directories:
touch -t `date +%m%d0000` /tmp/$$
find /tmefndr/oravl01 -type f -newer /tmp/$$
rm /tmp/$$
The first command can be modified to specify other date and time,\\
so that the commands will return all files that have changed since that particular date and time.
find . -type f -mtime +14 -ok rm -f {} \;
Confirm before delete \\
All files older then 14 days in root of location will be deleted with confirmation.