I have the need to get information about a specific directory, basically I need to know the correlation between small, medium and big files.I came up with this:for i in K M G; do  printf $i  du -h /usr/opt |    awk '{print $1}' |    grep ${i}$ |    wc -ldone | tee /stat.outfrom the result then I add all numbers and subtract the total to obtain the number of files under 1k. ( I presume we have a lot of them since it's source files) Anyway, this way is good for small directories, I actually have a very big one (expecting over 1Tera) and no idea of the files distribution.I need to copy all these files to a private storage and need to give a estimate time on the copy.I was thinking on the line of doing something as this:find pwd |xargs ls -lph |awk '{print $5}' But I miss what I should put after or if I should take another approach. Any help would be most welcome.
how obtain directory files info
shell script;solaris
If you can use GNU find (non-embedded Linux or Cygwin), make find print the file sizes and post-process the output with awk to sort each size into a category, sort and uniq to group by categories, and awk or sed to pretty-print the result. Something like:find /usr/opt -type f -printf '%s\n' |awk '{    if ($1 ~ /^[2-9]......../) { print 3 G }    else if ($1 >= 1073741824) {  print 3 G }    else if ($1 >= 1048576) { print 2 M }    else if ($1 >= 1024) { print 1 k }    else if ($1 >= 1) { print 0 }}' |sort | uniq -c |awk '{print $1  files are in the  $3 B range}'