home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pmafire!news.dell.com!swrinde!sdd.hp.com!usc!hacgate!carmi
- From: carmi@ipld01.hac.com (Aviram Carmi)
- Newsgroups: comp.lang.perl
- Subject: Re: Columnization
- Message-ID: <23288@hacgate.SCG.HAC.COM>
- Date: 14 Sep 92 18:55:17 GMT
- References: <1992Aug5.182712.14285@athena.mit.edu> <BtM68r.J0A@NCoast.ORG> <1360@minya.UUCP>
- Sender: news@hacgate.SCG.HAC.COM
- Organization: Hughes Aircraft Company - Canoga Park, CA
- Lines: 49
-
- In article <1360@minya.UUCP> jc@minya.UUCP (John Chambers) writes:
- >> | Consider the example from the manual page:
- >> | ls | paste - - - -
- >> | This is supposed to produce four-column output. It does put the names
- >> | four to a line, but in most directories, they will not be in columns.
- >> | There seems to be no options that will produce columnar output.
- >>
- >> pr -m -t -w# file1 file2 ...
- >>
- >> where # is the width (default 72). May be System V only.
- >
- >Several people have suggested something like this, but I don't see any
- >way that you can use pr to columnize the output of ls like the above
- >"ls | paste" command does (but correctly ;-). To do so, you would need
- >a filter that reads ls's output and writes it into N files, and then
- >feed these files to pr, and then remember to delete the intermediate
- >files. If you're going to write this filter, well, you might just as
- >well have it write a single file (stdout) instead and align the fields
- >itself. So pr doesn't help you at all. If you have to write a program
- >to chop up the data into multiple files, it's just as easy to write
- >your own program in C or perl to do the entire job.
- >
-
- I tried to e-mail but it bounced, so here it goes:
-
- How about:
-
- "ls | pr -l1 -t -w100 -4"
-
- where 100 is the total width and 4 is the number of columns you want.
-
- Here is sample output from my home directory:
- InternetResourceGuide/ Mail/ Mitch News/
- canada/ emacs/ fx4bin/ fx800bin/
- perl/ script/ src/ sun4bin/
-
-
- -avi
-
- --
- Aviram Carmi EMail: carmi@ipld01.hac.com Phone: (818) 702-3179
- Snail Mail: Hughes Aircraft M/S 262/C64
- P.O. Box 7928 Canoga Park, CA 91309-7928
-
-
- --
- Aviram Carmi EMail: carmi@ipld01.hac.com Phone: (818) 702-3179
- Snail Mail: Hughes Aircraft M/S 262/C64
- P.O. Box 7928 Canoga Park, CA 91309-7928
-