At 2013-03-04 20:13:46,"Paul de Weerd" <[email protected]> wrote:
>Exactly! So what is the point in summing up the sizes of a bunch of
>files ? I am 197 cm tall, my house number is 34, my zipcode is 1318,
>I have 2 brothers and 1 sister .. sum is 1552. Great, but now what ?
>
>This total value does not correspond to anything tangible (as far as I
>can see, at least .. hence me asking). It's no indication of how much
>storage space is needed to store these files, it's no indication of
>how large an archive would be containing these files, it's of no real
>use (again, afaics) except for knowing what the filesize would be of
>cat * > /tmp/newfile (which would be pointless in most cases I guess).
>
>Why do people care ?
>
Maybe because we come from Windows system.
In Windows, sum files' size by "Byte" is a simple quick way to check if
thousands of files are
modified/sync/same, although not accurate.
In OpenBSD, Command ls or du can't do this directly.
For example
# pwd
/home/test
# ls -l
total 8
-rw-r--r-- 1 root wheel 2 Mar 3 23:29 a.txt
-rw-r--r-- 1 root wheel 3 Mar 3 23:29 b.txt
# du -sh
6.0K .
# du -s
12 .
# echo a >>b.txt
# ls -l
total 8
-rw-r--r-- 1 root wheel 2 Mar 3 23:29 a.txt
-rw-r--r-- 1 root wheel 5 Mar 4 21:45 b.txt
# du -sh
6.0K .
# du -s
12 .
You see? ls and du never know this directory's files(withtout subdirectory)
have been changed, but file sizes are changed from 5 to 7, so "sum" knows and
Tedu's shell script is my friend.
Tedu's filesizes script.
~/bin> cat filesizes
#!/bin/sh
ls -l $@ | awk '{sum += $5} END { print sum }'
Would function like this script merge to ls' options or other command to
OpenBSD base?