System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to Check the files in sub folders

SOLVED
Go to solution
syedar
Advisor

Script to Check the files in sub folders

Hi all,
I need script to check whether the files exist in sub folders(A1,A2 and A3) then move the files to hold directory in each sub folder and compress the recent moved files and delete the files which is older than 7 days from hold directories of each sub folders.

directory structure is:
1./HOME/A1/hold
2./HOME/A2/hold
3./HOME/A3/hold
4 REPLIES
Steven E. Protter
Exalted Contributor

Re: Script to Check the files in sub folders

Shalom,

partial

find +mtime 7 -exec rm -f

http://www.dba-oracle.com/t_script_remove_oracle_archived_redo_log_files.htm

http://www.computing.net/answers/unix/delete-old-files-/7593.html

to do multiple directories.

Make a file called list with the locations:

/HOME/A1/hold
/HOME/A2/hold
/HOME/A3/hold

while read -r filename
do

done < list

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ganesan R
Honored Contributor
Solution

Re: Script to Check the files in sub folders

Hi Syedar,

Use this script..


for A in A1 A2 A3
do
if [ -f /HOME/$A/* ]
then
for i in `ll /HOME/$A |grep -v ^d | awk '{print $9}'`
do
compress /HOME/$A/$i
mv /HOME/$A/$i.Z /HOME/$A/hold
find /HOME/$A/hold -mtime +7 -exec rm -rf {} \;
done
fi
done
Best wishes,

Ganesh.
syedar
Advisor

Re: Script to Check the files in sub folders

it works fine.

Thanks Ganesan R
syedar
Advisor

Re: Script to Check the files in sub folders

Thanks