[clug] Disk vs file size

Brett Worth brett.worth at gmail.com
Thu Aug 8 22:02:50 UTC 2019


On 8/8/19 5:44 pm, Brett Worth wrote:
> How about:
>
>     $ find . -type f -ls | awk ' { sum+=$2; } END {print sum*1024*1024; } '
>
> The second column of the -ls output  is the block count so the multiplier needs to match
> your block size.

I should have read the man page.  the find "-ls" is always 1K bytes  unless the
POSIXLY_CORRECT variable is set in which case it's 512 bytes.

So my command should have bee:
   
   $ find . -type f -ls | awk ' { sum+=$2; } END {print sum*1024; } '

Brett

-- 
  /) _ _ _/_/ / / /  _ _//
 /_)/</= / / (_(_/()/< ///




More information about the linux mailing list