Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet thread from rec.arts.ascii, started 6 Mar 1995.
 _   _                     _        _             _     _           
| | | |___  ___ _ __   ___| |_     / \   _ __ ___| |__ (_)_   _____ 
| | | / __|/ _ \ '_ \ / _ \ __|   / _ \ | '__/ __| '_ \| \ \ / / _ \
| |_| \__ \  __/ | | |  __/ |_   / ___ \| | | (__| | | | |\ V /  __/
 \___/|___/\___|_| |_|\___|\__| /_/   \_\_|  \___|_| |_|_| \_/ \___|
Script: Centering

Script: Centering

rec.arts.ascii · 1 message · 6 Mar 1995
Tony Nugent <T.N...@SCT.GU.EDU.AU> ASCII art 6 Mar 1995 08:32 · raw headers · report
>         Does anybody have a script that centers text or pictures or whatever?
> I know this is only a really simple tr command, but I can't figure it out
> right now. :) Thanks...

Try this:

========8<----insert-crowbar-here-------------------------------
#!/usr/bin/awk -f
# centre all input text on an 80-column line
{
  if ( length < 78 ) {
    le = ( 80-length ) / 2 ;
    for ( i=1 ; i<=le ; i++ ) {
      printf(" ")
    };
  } print $0
}
========8<----insert-crowbar-here------------------------------

Seems to work ok for me :-)

If you haven't got an 80-column display, or don't want to centre
between columns 1 and 80, then this should be able to be modified
so that it can take paramaters to set the centering margins.

Hope this is useful.

Cheers
Tony
          _______________________________________________________
  _______|      Tony Nugent    |       Griffith University       |______
  \      |                     | Brisbane, Queensland, Australia |     /
   \     |-------------------------------------------------------|    /
    >    |  T.N...@sct.gu.edu.au  tnu...@gucis.cit.gu.edu.au  |   <
   /     |_______________________________________________________|    \
  /__________)                                               (_________\
         Kelly: " Mom, when I grow up I want to be just like you. I want to do
                                 nothing, I want to be nothing."
  -=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=-

About this thread. These messages were posted publicly to the newsgroup rec.arts.ascii in 1995 and are mirrored here unchanged as part of the Historic Archives – only email addresses are masked. The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can. Are you one of the authors? Contact us to get your posts attributed, connected to your artist profile, or removed.

Report this message

Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.

Help classify this post