size of regular file
how to find the total size of regular files
|
Quote:
Code:
find . -name "<whatever pattern you want>" -ls | awk '{total += $7} END {print total}' |
I think you need to define your request in more detail. What do you mean by "total size" exactly? Of all files on the system, on a partition, in a directory, owned b a user, what? Are there any other conditions or requirements involved?
Have you taken a look at the du application yet? |
@TBOne
I always get mesmerized by awk's line processing beauty, so following your logic I did something like this. Code:
[user01@centos-flash ~]$ls -l|awk '{ print $5}' Please help me understand. Thanks |
i got its correct answer
thanx all i did Code:
|
Quote:
Quote:
|
Quote:
Quote:
|
but by using grep '^-' we are saying that is should be a regular file
and in ls -l 5 th field gives the size of regular file is n't it??????????? den where is the wrong ???? |
Quote:
|
All,
are we safe to assume that Code:
ls -l |grep "^-"|awk '{ total+= $5 } END {print total} Thanks unSpawn for that url it is pretty good,I was shocked though! |
Quote:
|
Quote:
Code:
find -type f -exec stat --printf="%s\n" {} \; | awk '{size+=$1}END{print size}' Code:
ls -l |awk '/^-/{ total+= $5 } END {print total}' Cheers, Tink |
Code:
find -type f -exec stat --printf="%s\n" {} \; | awk '{size+=$1}END{print size}' It works wonders. Since I wanted only files in current directory and not sub-directories I did something like this. Code:
find . -maxdepth 1 -type f -exec stat --print="%s\n" {} \;|awk '{size +=$1} END {print size}' Code:
find . -maxdepth 1 -not -name ".*" -exec stat --print="%s\n" {} \; |awk '{size += $1} END {print size}' http://www.linuxquestions.org/questi...814/page2.html Another member is helping me but I would also like your input on how to stop searching for "some" directories for some reason it is not working... Thank you for your assistance. |
All times are GMT -5. The time now is 10:25 AM. |