Re: ls -s vs. du (was: Re: [dev] [st] font fallback)

From: Raphael Proust <raphlalou_AT_gmail.com>
Date: Mon, 7 Jan 2013 09:29:53 +0000

On Sun, Jan 6, 2013 at 2:02 PM, Strake <strake888_AT_gmail.com> wrote:
> On 06/01/2013, pancake <pancake_AT_youterm.com> wrote:
>> Didnt checked, but i guess that ls -s show size in bytes and du in block
>> bytes, which depends on filesystem.
>
> Nope. Both show size in blocks [1].
>
> It seems proper to do so in ls alone, with a flag of whether to add
> sizes of all files below; thus we could drop du. One may argue that
> the job of ls is not to add sizes, but now we have 2 utilities what
> list files, which loses.

Real difference is du handles hard links (i.e. shows actual disk usage
(as one would expect) by counting hard-linked files only once) while
ls list files (as one would expect) (and optionally gives some
information about them). Which wins.

$ mkdir baz
$ cd baz
$ echo blahblahblahblahblah >foo
$ ln foo bar
$ ln bar x
$ ln foo y
$ ls -s .
total 16
4 bar 4 foo 4 x 4 y
$ du -s ./*
4 ./bar
$ du -s .
8 .
$ ls -sd .
4 ./


Cheers,
-- 
______________
Raphaƫl Proust
Received on Mon Jan 07 2013 - 10:29:53 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 07 2013 - 10:36:04 CET