home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3169 < prev    next >
Encoding:
Text File  |  1992-07-28  |  1.0 KB  |  35 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!mcsun!sunic!ugle.unit.no!news
  3. From: Harald.Eikrem@delab.sintef.no
  4. Subject: Re: script to center text
  5. In-Reply-To: tchrist@convex.COM's message of 28 Jul 92 15:16:23 GMT
  6. Message-ID: <1992Jul28.233633*Harald.Eikrem@delab.sintef.no>
  7. Followup-To: comp.unix.shell
  8. Sender: news@ugle.unit.no (NetNews Administrator)
  9. Organization: SINTEF DELAB, Trondheim, Norway.
  10. References: <AeRB8p600WB60JlPZc@andrew.cmu.edu> <josef.712322528@uranium>
  11.     <1992Jul28.151623.12798@news.eng.convex.com>
  12. Date: 28 Jul 92 23:36:33
  13. Lines: 20
  14.  
  15. This is a possible sed centering solution, but them y'know, I'm a sed
  16. loonie.....
  17. Note that the very first substitution trades any tabs for 4 spaces,
  18. because there wont be a single *correct* way to interpret a tab after
  19. the centering operation has taken place....
  20.  
  21. ===================
  22. #!/bin/sh
  23.  
  24. sed '
  25.     s/    /    /g
  26.     s/^  *//
  27.     s/  *$//
  28.     : fill
  29.     /.............................................................................../!s/.*/ & /
  30.     t fill
  31. ' $@
  32. ===================
  33.  
  34.   ~~harald E.
  35.