Script: purge files more than N days old. Need Non Recursive Find
source file contains paths of the directories from which files need to be purged (older than N days)
From above file I read each path line by line. For each line I need to remove the files under that directory one by one.
I am using foll. command on AIX.
find $purge_dir_path -type f -mtime N -print | xargs rm -f
Find does a recursive search & traverses through all the subdirectories.
I am looking to restrict the search only to the directory specified by $purge_dir_path excluding its subdirectories.
I tried -maxdepth option. Even if the man find lists -maxdepth, the command doesn't run.
bash-2.05b$ find . -type f -maxdepth 0 -mtime +30 -print
find: bad option -maxdepth
I tried for -prune option, but since subdirectory names are not fixed for each directory to be purged, it seems to be ruled out.
I have even tried -xdev option. It doesn't work either.
I think you have no chance to do it in a single find in AIX, but you can combine a find with a grep:
Bingo! It worked. I used while loop containing find + grep command.
Thanks for your reply.
is it possible you can send me a copy of this script?
|All times are GMT -5. The time now is 08:54 PM.|