Quote:
Originally Posted by kirukan
find * -type f -mtime 10
|
This does not print anything since you cannot use a wildcard as the search path: if you want to start your search from the current directory use a dot or if you want to start from another point, just use its full (or relative) path. For example, these ones are valid
Code:
find . -type f -mtime 10
find /usr/local -type f -mtime 10
Take in mind that the wildcard is expanded by the shell with all the (not hidden) items in the current directory and the resulting command line is a non-sense.
Another clue is that you will not find exactly the files last modified on December 25th using -mtime 10, first because if you subtract 10 days from 3rd of January you get the 24th of December, second because you have to consider the rounding effect of timestamp. Here is an explanation for the -atime predicate from the GNU find man
Code:
When find figures out how many 24-hour periods ago the file was last accessed,
any fractional part is ignored, so to match -atime +1, a file has to have been
accessed at least two days ago.
The GNU find has addressed the problem introducing the -daystart option, to match relative times from the 00:00 of the current day. Unfortunately you don't have this facility in solaris.
Regarding the total size calculation here are two methods (depending on what commands are available on your solaris box):
1) just use find and ls (using the -exec predicate) and sum the file sizes by piping the output to awk (as suggested by GooseYArd above)
Code:
find . -type f -mtime 10 -exec ls -l {} \; | awk '{sum += $5} END{print sum}'
2) if you have the GNU find (Solaris 8 provided a lot of GNU commands prepending a "g" to the command name) you can take advantage of the -printf predicate to print out just the file sizes:
Code:
gfind . -type f -mtime 10 -printf "%s\n" | awk '{sum += $1} END{print sum}'
Hope this helps.