ls -lR summary generator (nawk & sed)

Liam R. E. Quin lee at sq.sq.com
Sat Dec 9 09:28:57 AEST 1989


In article <3620 at convex.UUCP> tchrist at convex.COM (Tom Christiansen) writes:
about my little "lsabbrev" program:
>| The enclosed little shell script uses sed and nawk to take the output of
>| ls -l or ls -lR (sysV or BSD) and produce output that looks like
>| Sep86 42.0K arp
>Let's see I've I understand this -- you're just rearranging ls -l output,
>right? 
Correct.

> And are sizes the sizes really accurate?  I usually prefer to know 
> blocks used then sizes by byte, for which you'd want the 'ls -sl'
> output.  Otherwise you'll be charged for the holes in the files.

Well, it depends why you want to know.  One use is to produce a rather
terser summary of the "ls-lR" files at most ftp sites.  There, the size is
an indication of how long it'd take to ftp the file (over a busy SL/IP
serial connection) to the local machine.  You don't have the choice of
changing the options to ls here, especially if you're using anonymous uucp.

Another use is to keep a printed record of files that are on a tape.  The
size tells me how much space they are on the tape, and how large they
will be when they are restored, as most archiving software does not put
the holes back into the files.

So no, the sizes are a rough guide, that's all.


>|It's an example of using awk to post-process ls output, something I seem
>|to do once every couple of years...  Please, no perl one-liner equivalents!

>How come?  Nawk isn't available via anonymous FTP or automatic UUCP
>as perl is.
Well, GNU Awk is at least as available as perl, and seems to be somewhat
more stable.  And nawk is supplied with System V these days, and you can
get it for DOS (ugh) from MKS, and nawk is on the AT&T toolchest, so this
statement .

Also, I was trying to say that I wasn't interested in starting off yet
another "perl is better than awk because it takes less characters"
argument of the sort that is so off-putting to people who are not yet
familiar with perl.

>And the author himself admits in 
>comments that there are various version of nawk, some of which would
>make certain constructs work, others which would not.
And every perl program works on every version of perl, and there are no
incompatible features, eveon on DOS or the 286, right?

>[sed script]
>yielding output beginning like this (from /etc):
> 192 Oct  3 11:20 rpc.lockd*
> 176 Oct 11  1988 restore*

Actually I did start with a sed script...
Trouble is, the ls -lR files on uunet, etc., are not in ls -FsRl format.
Also, the data in lsabbrev ouptput is in columns of equal width, and is
terser even if files are several megabytes large:
> 128 Oct 11  1988 cron*  < your sed script
> Dec89 24.3K OUT.3	  < lsabbrev

>|I also have a version of pr (sort of) that works out how many columns
>|to use on a per-page basis, [...]

>I posted a similar tool in perl to alt.sources a while back called "words".
>This kind of thing does save paper. [...]
Well, that was the idea.  I wrote "lsabbrev" to print out a huge ls -lR
listing with "pfm" putting as many columns on the page as would fit.
That's why I wanted it as narrow as possible.

I've had lots of requests for "pfm", so I have sent it to comp.sources.misc
for ++Brandon peruse and maybe post.

>		 "EMACS belongs in <sys/errno.h>: Editor too big!"
Perl is small and elegant, I suppose?   :-)			:-(

Lee
-- 
Liam R. Quin, Unixsys (UK) Ltd [note: not an employee of "sq" - a visitor!]
lee at sq.com (Whilst visiting Canada from England, until Christmas)
 -- I think I'm going to come out at last...
 -- What?  Admit you're not a fundamentalist Jew?  They'll *crucify* you!  :-)



More information about the Alt.sources.d mailing list