Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 26fd3f8981a360c4bbc64a7fd8b9c6ca > files > 132

bash-doc-2.05b-12mdk.ppc.rpm

#! /bin/bash
#
# center - center a group of lines
#
# tabs in the lines might cause this to look a little bit off
#
#

width=${COLUMNS:-80}

if [[ $# == 0 ]]
then
	set -- /dev/stdin
fi

for file
do
	while read -r
	do
		printf "%*s\n" $(( (width+${#REPLY})/2 )) "$REPLY"
	done < $file
done

exit 0