home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sources.wanted:3765 alt.sources.wanted:1287
- Newsgroups: comp.sources.wanted,alt.sources.wanted
- Path: sparky!uunet!darwin.sura.net!convex!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: script to center text
- Message-ID: <1992Jul28.104619.13095@news.eng.convex.com>
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Nntp-Posting-Host: pixel.convex.com
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- Organization: CONVEX Realtime Development, Colorado Springs, CO
- References: <AeRB8p600WB60JlPZc@andrew.cmu.edu>
- Date: Tue, 28 Jul 1992 10:46:19 GMT
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 25
-
- From the keyboard of es2j+@andrew.cmu.edu (Edward John Sabol):
- :Could someone post a awk, perl, or sed script which can center text. I'd
- :like to be able to pipe a file or region into it and get out the same
- :text only centered in 80 columns.
- :
- :It shouldn't be hard to do, but I don't know awk or perl very well. I
- :can do it in C, of course, but I want a script for ease of portability
- :and the smaller size. Speed needn't be an issue.
-
- This should do it for you:
-
- perl -pe 'print " " x int((81 - length())/2)'
-
- Beware tabs: convert them with expand, or do it yourself:
-
- perl -pe '1 while s/\t+/" " x (length($&) * 8 - length($`) % 8)/e;
- print " " x int((81 - length())/2)'
-
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
-
- I want to be Robin to Bush's Batman. --Vice President Dan Quayle
-