Partition script output question

Hello Everyone! I have a file called �cells� with 3 set of #'s, roughly 400+ lines. My current tool "movrcs" grabs the �cells� file, and creates one huge �mov_rcs� script which is a problem. I want the tool to grab 20 lines of the "cells" file at a time, and create separate script files for them, not one huge output script. Any assistance is greatly appreciated!!!! :smiley:

omp root> cat cells

  62 33 34 
  103 44 43 
  104 44 43 
  105 44 43 
  106 44 43 
  107 44 43 
  108 44 43 
  109 44 43 
  110 44 43 
  112 44 43
  

�Output truncated, there are over 250+ lines

omp root> cat movrcs

while read cell prim alt
  do
   
  echo "/omp/bin/TICLI -1 move:rcs $cell,altap $alt" >> mov_rcs
  echo "sleep 20" >> mov_rcs
  echo "/omp/bin/TICLI -1 move:rcs $cell,priap $prim" >> mov_rcs
  echo "sleep 40" >> mov_rcs
   
  done < cells

ompeps root> cat mov_rcs

/omp/bin/TICLI -1 "move:rcs 62,altap" 34
  sleep 60
  /omp/bin/TICLI -1 "move:rcs 62,priap" 33
  sleep 60
  /omp/bin/TICLI -1 "move:rcs 103,altap" 43
  sleep 60
  /omp/bin/TICLI -1 "move:rcs 103,priap" 44
  sleep 60
  /omp/bin/TICLI -1 "move:rcs 104,altap" 43
  sleep 60
  /omp/bin/TICLI -1 "move:rcs 104,priap" 44
  sleep 60
  �..output truncated

Please post sample exact expected output, and mention what Opaerating System and version you use, and what Shell your posted code requires.

The sample output has been provided, its called mov_rcs file. See above for my request, thanks!

root> uname -r
5.10
root> cat /etc/release
                      Solaris 10 10/08 s10s_u6wos_07b SPARC
           Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 27 October 2008

Something like this? Create a new script file every 20 lines from the input file. Each output script file contains 40 primary commands and 40 sleep commands. Untested. Output format and sleep values are based on your sample output format not on the original script.

#!/bin/ksh
counter=0
prefix="mov_rcs"
suffix=1
while read cell prim alt
do
     counter=$(( ${counter} + 1 ))
     if [ ${counter} -gt 20 ]
     then
          suffix=$(( ${suffix} + 1 ))
          counter=0
     fi
     scriptfile="${prefix}.${suffix}"
     echo "/omp/bin/TICLI -1 \"move:rcs $cell,altap\" $alt" > "${scriptfile}" 
     echo "sleep 60" >> "${scriptfile}"
     echo "/omp/bin/TICLI -1 \"move:rcs $cell,priap\" $prim" >> "${scriptfile}"
     echo "sleep 60" >> "${scriptfile}"
done < cells