home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!mcsun!sunic!ugle.unit.no!news
- From: Harald.Eikrem@delab.sintef.no
- Subject: Re: script to center text
- In-Reply-To: tchrist@convex.COM's message of 28 Jul 92 15:16:23 GMT
- Message-ID: <1992Jul28.233633*Harald.Eikrem@delab.sintef.no>
- Followup-To: comp.unix.shell
- Sender: news@ugle.unit.no (NetNews Administrator)
- Organization: SINTEF DELAB, Trondheim, Norway.
- References: <AeRB8p600WB60JlPZc@andrew.cmu.edu> <josef.712322528@uranium>
- <1992Jul28.151623.12798@news.eng.convex.com>
- Date: 28 Jul 92 23:36:33
- Lines: 20
-
- This is a possible sed centering solution, but them y'know, I'm a sed
- loonie.....
- Note that the very first substitution trades any tabs for 4 spaces,
- because there wont be a single *correct* way to interpret a tab after
- the centering operation has taken place....
-
- ===================
- #!/bin/sh
-
- sed '
- s/ / /g
- s/^ *//
- s/ *$//
- : fill
- /.............................................................................../!s/.*/ & /
- t fill
- ' $@
- ===================
-
- ~~harald E.
-