Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I control paging in a while loop

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
This code does not perform the "read answer" command (any ideas ) ? I am trying to page after 20 lines.

while read SRV DATE TIME USER
do printf "| %-8s | %10s | %6s | %6s |\n" $SRV $DATE $TIME $USER
let CNT=$CNT+1
if [[ $CNT -ge 20 ]]
then
echo "Press enter to continue...\c"
read answer
CNT=0
fi
done < tmpfile
 
The &quot;read answer&quot; line is getting its input from the same place the &quot;while read&quot; loop control is getting its input.

My suggestion would be to remove the paging control you've got there, and pipe the output of the entire run through more or less.

Alternatively, you could also write your script to write a child script with 20 iterations of work followed by an iteration of pausing, and so on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top