Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get the number of files

Status
Not open for further replies.

pho01

Programmer
Mar 17, 2003
218
US
What command do I run to get the number of files on a share server in which modified date is greater than 30 minutes ago?

for instance:
I'm on a unix box named: unix1

I want to get the number of files in which modified dates are greater than 30 minutes ago. these files are located on a shared windows server at this location:
\\nshare\path\targetdir

We need to keep track of the logs...
Thanks much
 
well this is a whole host of commands ...

first you need to get to get the files from the windows box.

you could use samba for this, possibly using smbtar and piping the file to the directory of your choice.

you then need to check the time of a file ... 30mins is too small for 'find' normally (find is limited to days).

perl could do it i guess.

if (time - (stat($file))[9] > (30*60)) {print $file}

would do it i guess.

then you could just 'wc -l' to get the number of files.

so you could enter ... get ready:

Code:
cd <directory to place files> ;
smbtar -s <server> -u <user> -p <password> -x <share on server> -d <subdirectory> -t - | tar xvf -
find . -type f -exec perl -el '$f=$ARGV[0];if(time-stat($f))[9]>(30*60)){print $f}' {} \; | wc -l

well it might work for you :)
 
find /your/directory/ -name &quot;*.*&quot; -cmin +30

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
Sorry, you want the number of files:

find /your/directory/ -name &quot;*.*&quot; -cmin +30 | wc -l

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
my find doesn't have the cmin option ...

 
nope, no '-c' ... I'm not using GNU tho, i'm on Solaris.
 
Provided you use ksh and don't work between midnigth and 00:29 you can try something like this:
Code:
day=$(date &quot;+%m%d&quot;)
typeset -Z2 hr=$(date &quot;+%H&quot;)
typeset -Z2 mn=$(date &quot;+%M&quot;)
if [ $mn -ge 30 ]; then
  mn=$((mn - 30))
else
  mn=$((mn + 30))
  hr=$((hr - 1))
fi
touch -t &quot;$day$hr$mn&quot; /tmp/stamp$$
find path/to/dir -type f ! -newer /tmp/stamp$$ -print

Hope This Help
PH.
 
But the thing is, how to connect to the windows net share directory? It's a shared dir, no username and password required.

smbtar does not work for me. It said: not found.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top