home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5922 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.3 KB

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