Patch-ID: bash40-021
[bash.git] / examples / scripts / center
blob8d367d309129e97371049fab69484625394922ac
1 #! /bin/bash
3 # center - center a group of lines
5 # tabs in the lines might cause this to look a little bit off
9 width=${COLUMNS:-80}
11 if [[ $# == 0 ]]
12 then
13 set -- /dev/stdin
16 for file
18 while read -r
20 printf "%*s\n" $(( (width+${#REPLY})/2 )) "$REPLY"
21 done < $file
22 done
24 exit 0