issues programming a script in BASH
I am working through a book about scripting in UNIX, and I cannot get the follwing script to work correctly.
#center_text row_number input_text_file
cat $* | \
while read input_text
line_length='echo $input_text | wc -c'
tput cup $row_number \ 'expr \( $term_cols - $line_length \) / 2'
row_number='expr $row_number + 1'
if [ $row_number -ge $max_lines ]
echo "Too many lines for the screen"
The issue is that the -ge statement is getting two many inputs because the $row_number variable is evaluating to expr $row_number + 1 as a string instead of a number. I tried using (()) notation and using the ` instead of the ', as well as a host of other solutions, but none seem to work. I am sure that the solution is simple, and I am an idiot, but if anyone can post what I am doing incorrectly, I would greatly appreciate it. Thanks