[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49994: upgrade: have "-s" of 'ls' display alloc'd sizes for specifie

From: L A Walsh
Subject: bug#49994: upgrade: have "-s" of 'ls' display alloc'd sizes for specified "--block-size"
Date: Fri, 20 Aug 2021 00:02:46 -0700
User-agent: Thunderbird (Windows/20100228)

On 2021/08/18 08:39, Paul Eggert wrote:
Perhaps your request would be more clear if you gave a specific example of what you want and why --block-size doesn't do what you want.

I wanted to use ls to list the size of files in bytes, and use
Binary prefixes K=1024, M=1024**2, G=1024**3 to display
the the numeric portion with a maximum 3 digits or
use a floating point format with up to 1 digit to the right
of the decimal point: similar and as rounded by use of "%.1f"
as in printf.

Using a list of 577 files in file "files.txt", the existing 'ls'

cat files.txt|xargs /usr/bin/ls --block-size=1 -1dhsS

Instead of displaying the file sizes in bytes, it showed them
rounded to the nearest 4K, so sorting by size and displaying
only the 1st of a given size, I only ended up with 13 unique file-sizes in the list:

312K lib/perl5db.pl
200K lib/Unicode/Collate/Locale/ja.pl
100K lib/Unicode/Collate/Locale/zh_pin.pl
96K ext/XS-APItest/t/utf8_warn_base.pl
36K regen/opcode.pl
32K ext/DynaLoader/DynaLoader_pm.PL
28K regen/feature.pl
24K ext/XS-APItest/t/handy_base.pl
20K Porting/checkURL.pl
16K Porting/corelist.pl
12K t/lib/dbmt_common.pl
8.0K dist/lib/lib_pm.PL
4.0K cpan/Pod-Simple/t/ascii_order.pl

I expected closer to 100 or more files displayed with size under
1000 bytes.

If 'ls' used the user-specified 'block-size' of 1 byte, the number
of files displayed is actually 279, or over 20 times the number
of files with some names elided for sake of brevity.

310K  lib/perl5db.pl
197K  cpan/Unicode-Collate/Collate/Locale/ja.pl
138K  regen/mk_invlists.pl
126K  Porting/bisect-runner.pl
53.3K win32/bin/search.pl
52.1K cpan/IO-Compress/t/compress/generic.pl
49.9K t/test.pl
46.4K utils/perlbug.PL
17.4K Porting/pod_lib.pl
17.1K Porting/add-package.pl
6.7K  dist/Devel-PPPort/Makefile.PL
6.6K  cpan/Sys-Syslog/Makefile.PL
6.5K  cpan/podlators/Makefile.PL
5.5K  cpan/Unicode-Collate/Collate/Locale/da.pl
5.4K  symbian/makesis.pl
1.2K  ext/Hash-Util/Makefile.PL
1.1K  win32/bin/perlglob.pl
1.0K  ext/File-Glob/Makefile.PL
997  cpan/Unicode-Collate/Makefile.PL
983  cpan/Unicode-Collate/Collate/Locale/mk.pl
125  dist/Time-HiRes/hints/sco.pl
110  ext/VMS-DCLsym/Makefile.PL
104  dist/Time-HiRes/hints/dynixptx.pl
101  cpan/DB_File/hints/dynixptx.pl
97  ext/POSIX/hints/mint.pl
94  dist/IO/hints/sco.pl
11  symbian/uid.pl
 6  t/op/svleak.pl
 3  t/run/dtrace.pl
 2  cpan/Module-Load-Conditional/t/to_load/LoadMe.pl


Instead 'ls' displays 4.0K for a file that is only 2 bytes.

Clearly it isn't using the block-size specified by the user
in the same way 'du' does:
cd /tmp
echo "1" >out.pl
du -b out.pl
2 out.pl
Ishtar:/tmp> /bin/ls --block-size=1 -1dhsS  /tmp/out.pl
4.0K /tmp/out.pl

When I use "-b" in du (equivalent to '--apparent-size --block-size=1),
I get a size of '2' which one would expect for a file with 2 chars in it.
however, ls displays 4.0K.  Clearly it isn't using the
--block-size=1 that 'du'  is using.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]