Sophie

Sophie

distrib > Mageia > 3 > x86_64 > by-pkgid > 03c48c16b5559c045c4b28738358ecbb > files > 185

bash-doc-4.2-53.1.mga3.x86_64.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