Use loop in script

Hi All
I want to make a script in which i can print prstat command output to a file in regular interval of 1 second
I am using below script for the same

dat=`date '+%d%m%y'`
echo "###########################################################"  >>prstat-$dat
date >>prstat-$dat
prstat 1 1 >>prstat-$dat
sleep 1

How to use loop here so that script can run till we do not terminate.

Check the description for a while loop in the man page of your shell or any of the many pages describing a while loop in shell scripting. Make it's condition "true" to have it loop endlessly.

Did you get a chance to search for similar threads in the forum? You will definitely find a bunch for sure.

old_dat=xxx
while [ 1 -eq 1 ]; do
  dat=`date '+%d%m%y'`
  if [ $dat != $old_dat ]; then
    outfile=prstat-$dat
    echo "#######" > $outfile
    old_dat=dat
  fi
  date >> $outfile
  prstat 1 1 >> $outfile
  sleep 1
done