Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jan 2001 01:19:59 -0600
From:      Philip Kizer <pckizer@nostrum.com>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: ls -h 
Message-ID:  <200101300719.f0U7JxN10913@magus.nostrum.com>
In-Reply-To: Your message of "Mon, 29 Jan 2001 21:53:30 PST." <200101300553.VAA16932@rushe.aero.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
"Mike O'Brien" <obrien@rushe.aero.org> wrote:
>	I don't know what 'ls -h' does on Linux, but 'ls -s' might do
>what you want.  It gives the size of the file in blocks, followed by
>the file name.  It's ideal for piping into 'sort'.

I have a feeling he means something to help parsing the numbers when you
start getting file sizes with more than 6 digits or so...

The first option is just to 'make install clean' in '/usr/ports/misc/gnuls'
and use the same option as on Linux as you'd then be using the same tool.

Personally, I never much cared for adding gnuls; I just don't like the way
it changes all file sizes to be no more than 3 digits with a multiplier
suffix (i.e.  21k, 951, 37k, 3.9k, 1.0M, 37k), as that doesn't jump out at
me visually enough.  So, I just use a small 3-line perl filter (it requires
Number::Format module for the hard work):

  --- commaize ------------------------------------
  #!/usr/local/bin/perl -wp
  # Trivial hack by Philip Kizer <pckizer@nostrum.com>
  use Number::Format qw(:subs);
  s/(^|\s)(\d{4,})/$1 $2/g;
  s/\s(\d{4,})/format_number($1)/ge;

then I just invoke it as "ls -l | commaize" when needed to help discern
really large file sizes.


-philip

-- 
Philip Kizer,
USENIX Liaison to Texas A&M University       <usenix@tamu.edu>
Texas A&M CIS Operating Systems Group, Unix <pckizer@tamu.edu>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101300719.f0U7JxN10913>