blob: dbe613363874b63bceae69f81c3dae018dedf1a4 [file] [log] [blame]
Jari Aaltobb706242000-03-17 21:46:59 +00001#! /bin/bash
2#
3# center - center a group of lines
4#
5# tabs in the lines might cause this to look a little bit off
6#
7#
Chet Rameyac50fba2014-02-26 09:36:43 -05008# Chet Ramey <chet.ramey@case.edu>
9#
10# Copyright 1999 Chester Ramey
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2, or (at your option)
15# any later version.
16#
17# TThis program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software Foundation,
24# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Jari Aaltobb706242000-03-17 21:46:59 +000025
26width=${COLUMNS:-80}
27
28if [[ $# == 0 ]]
29then
30 set -- /dev/stdin
31fi
32
33for file
34do
35 while read -r
36 do
37 printf "%*s\n" $(( (width+${#REPLY})/2 )) "$REPLY"
38 done < $file
39done
40
41exit 0