show dots when script is "thinking"

Hey, I'm running the following script:

#!/bin/bash

kjv=kjv.txt
trim(){
    local trim_string
    local _TRIM=$1
    trim_string=${_TRIM##*[${2:- }]}
    _TRIM=${_TRIM#"trim_string"}
    echo $_TRIM
}

#trim() {
#    echo $( _trim "$@" )
#}

printf "How many chapters? "
read response

while IFS=: read book chapter verse text
do
    #this is a temp variable!
    chapterCount=$response
    chapterNumber=$( trim "$chapter" 0 )
    if [ $chapterNumber -le $chapterCount ]
    then 
        firstword=${text%% *}
        printf "%s %s:%s %s\n" "$book" "$chapter" "$verse" "$firstword"
    fi
done < "$kjv"
printf "\n"

Basically it takes the first word out of each verse of a specified amount of chapters from a text file. Since the file is so large it takes some time and sometimes looks like its stuck. How can I add dots (periods) or something of that nature every time it's "thinking"?

line_count=0
blocksize=1000
while IFS=: read book chapter verse text
do
    line_count=`expr $line_count+1`
    if [ $line_count -gt $blocksize ]
      then 
         echo ".\c"
         line_count=0
     fi
    #this is a temp variable!
    chapterCount=$response
    chapterNumber=$( trim "$chapter" 0 )
    if [ $chapterNumber -le $chapterCount ]
    then 
        firstword=${text%% *}
        printf "%s %s:%s %s\n" "$book" "$chapter" "$verse" "$firstword"
    fi
done < "$kjv"

Some systems need "echo -e"
Adjust blocksize to suit.
You may have to adjust the output of the printf to go to a file, depending on how the script is called

I'm thinking, I'm thinking...I'm...thinking:

#!/bin/ksh
# busy - show progress indicators
# Heiner Steven (heiner.steven@odn.de)
#
#  usage:
#     busy& busipid=$!
#     # do some actions
#     kill $busypid
#  set -x 

#  Give some eye candy... 
set -A Indicators -- "\n  |o.............................|  " \
                     "\n  |0o............................|  " \
                     "\n  |)0o...........................|  " \
                     "\n  |()0o..........................|  " \
                     "\n  |0()0o.........................|  " \
                     "\n  |o0()0o........................|  " \
                     "\n  |.o0()0o.......................|  " \
                     "\n  |..o0()0o......................|  " \
                     "\n  |...o0()0o.....................|  " \
                     "\n  |....o0()0o....................|  " \
                     "\n  |.....o0()0o...................|  " \
                     "\n  |......o0()0o..................|  " \
                     "\n  |.......o0()0o.................|  " \
                     "\n  |........o0()0o................|  " \
                     "\n  |.........o0()0o...............|  " \
                     "\n  |..........o0()0o..............|  " \
                     "\n  |...........o0()0o.............|  " \
                     "\n  |............o0()0o............|  " \
                     "\n  |.............o0()0o...........|  " \
                     "\n  |..............o0()0o..........|  " \
                     "\n  |...............o0()0o.........|  " \
                     "\n  |................o0()0o........|  " \
                     "\n  |.................o0()0o.......|  " \
                     "\n  |..................o0()0o......|  " \
                     "\n  |...................o0()0o.....|  " \
                     "\n  |....................o0()0o....|  " \
                     "\n  |.....................o0()0o...|  " \
                     "\n  |......................o0()0o..|  " \
                     "\n  |.......................o0()0o.|  " \
                     "\n  |........................o0()0o|  " \
                     "\n  |.........................o0()0|  " \
                     "\n  |..........................o0()|  " \
                     "\n  |...........................o0(|  " \
                     "\n  |............................o0|  " \
                     "\n  |.............................o|  " \
                     "\n  |............................o0|  " \
                     "\n  |...........................o0(|  " \
                     "\n  |..........................o0()|  " \
                     "\n  |.........................o0()0|  " \
                     "\n  |........................o0()0o|  " \
                     "\n  |.......................o0()0o.|  " \
                     "\n  |......................o0()0o..|  " \
                     "\n  |.....................o0()0o...|  " \
                     "\n  |....................o0()0o....|  " \
                     "\n  |...................o0()0o.....|  " \
                     "\n  |..................o0()0o......|  " \
                     "\n  |.................o0()0o.......|  " \
                     "\n  |................o0()0o........|  " \
                     "\n  |...............o0()0o.........|  " \
                     "\n  |..............o0()0o..........|  " \
                     "\n  |.............o0()0o...........|  " \
                     "\n  |............o0()0o............|  " \
                     "\n  |...........o0()0o.............|  " \
                     "\n  |..........o0()0o..............|  " \
                     "\n  |.........o0()0o...............|  " \
                     "\n  |........o0()0o................|  " \
                     "\n  |.......o0()0o.................|  " \
                     "\n  |......o0()0o..................|  " \
                     "\n  |.....o0()0o...................|  " \
                     "\n  |....o0()0o....................|  " \
                     "\n  |...o0()0o.....................|  " \
                     "\n  |..o0()0o......................|  " \
                     "\n  |.o0()0o.......................|  " \
                     "\n  |o0()0o........................|  " \
                     "\n  |0()0o.........................|  " \
                     "\n  |()0o..........................|  " \
                     "\n  |)0o...........................|  " \
                     "\n  |0o............................|  " \


#  Make an array of the aforementioned eye candy... 
integer n=${#Indicators[@]}
integer i=0

#  While condition exists, present status to screen... 
while [[ -f bpc.txt ]] 2>/dev/null #true
do
   clear 
#   print -n -- "Running ... \n\t${Indicators}\n"
   print "Running ... \n\t${Indicators}\r"
   ((i=(i+1)%n))
#  sleep 1
#  clear
done

Note that you'd want to modify the condition that drives the while... loop.

What are all those block-characters in the print statement?

Instead of clearing the screen every time, try printing a carriage return instead of a newline. It will overwrite the last busy line with the next one.

hey, you're right...

So now I have:

#!/bin/bash

kjv=kjv.txt
trim(){
    local trim_string
    local _TRIM=$1
    trim_string=${_TRIM##*[${2:- }]}
    _TRIM=${_TRIM#"trim_string"}
    echo $_TRIM
}

#trim() {
#    echo $( _trim "$@" )
#}

printf "How many chapters? "
read response

line_count=0
blocksize=1000
while IFS=: read book chapter verse text
do
    line_count=`expr $line_count+1`
    if [ $line_count -gt $blocksize ]
      then 
         echo ".\c"
         line_count=0
     fi
    #this is a temp variable!
    chapterCount=$response
    chapterNumber=$( trim "$chapter" 0 )
    if [ $chapterNumber -le $chapterCount ]
    then 
        firstword=${text%% *}
        printf "%s %s:%s %s\n" "$book" "$chapter" "$verse" "$firstword"
    fi
done < "$kjv" 

and i get the following error:

integer expression expected
/home/administrator/bin/pk8-1: line 24: [: 0+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1

which is the line:

if [ $line_count -gt $blocksize ]

spaces are important.

line_count=`expr $line_count + 1`

Sorry, my heart was in the right place, but my syntax wasn't

hmm still not working

That's not much help; in what way is it not working?

#!/bin/bash

kjv=kjv.txt
trim(){
	local trim_string
	local _TRIM=$1
	trim_string=${_TRIM##*[${2:- }]}
	_TRIM=${_TRIM#"trim_string"}
	echo $_TRIM
}

#trim() {
#	echo $( _trim "$@" )
#}

printf "How many chapters? "
read response

line_count=0
blocksize=1000
while IFS=: read book chapter verse text
do
    line_count - `expr $line_count + 1`
    if [ $line_count -gt $blocksize ]
      then 
         echo ".\c"
         line_count=0
     fi
    #this is a temp variable!
    chapterCount=$response
    chapterNumber=$( trim "$chapter" 0 )
    if [ $chapterNumber -le $chapterCount ]
    then 
        firstword=${text%% *}
        printf "%s %s:%s %s\n" "$book" "$chapter" "$verse" "$firstword"
    fi
done < "$kjv"

returns the following error:
/home/administrator/bin/pk8-1-test: line 27: line_count: command not found

As I see it, the problem is at line 23, not 27.

line_count - `expr $line_count + 1`

and at line 32 (testing result of call to trim function), which doesn't return anything.