1833884 Members
2052 Online
110063 Solutions
New Discussion

Check the buffers

 
syedar
Advisor

Check the buffers

I need to check the files in sub sub folders older then 1 day and file prefix start with "*.dat" only, if present then display number of files along with folder name by find command.

Folder structure is:
/A/A1/A11..A20/
/A/A2/A21..A30/
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Check the buffers

Shalom,

A find command with the +mtime or +ctim parameter should do the trick.

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

Re: Check the buffers

Hi,


# find /A -depth -mtime +1 -name \*.dat
Best wishes,

Ganesh.
Ganesan R
Honored Contributor

Re: Check the buffers

Hi Syedar,

If you want to search in multiple folers and list the number of files with folder name write a small script like this.

Example, want to list number of files along with folder name which is older than 1 day in following folders.
/A/A1/A11, /A/A1/A12, /A/A1/A13, /A/A1/A14, /A/A1/A15 .... /A/A1/A20

cd /A/A1
for i in A11 A12 A13 A14 A15 ... A20
do
echo "$i `find $i -mtime +1 -name "*.dat"|wc-l`"
done
Best wishes,

Ganesh.
Matthias Zander
Advisor

Re: Check the buffers

Hi,

the first find looks for directories which contains files older then 1 day (-mtime +1). "sort -u" makes sure, that you get the directory only one time.

the second find will count the files

for dir in `find . -name "*.dat" -type f -mtime +1 -exec dirname {} \;| sort -u`
do
echo "$dir \c";
find $dir -name "*.dat" -type f -mtime +1 | wc -l
done
syedar
Advisor

Re: Check the buffers

Thanks for all.