Help with shell scripts for Informatica and mainframes

I am poor at scripting.Can any one help me write a script which parametrizes the script here .

#!/bin/bash                                                 

`rm file1.txt`
lineCount=0
newRec=1

IFS=`echo "\n\c"`
while read line
do

	lineCount=$(($lineCount + 1))
	
	#check is it a newRec, it was default to 1
	if [ $newRec = 1 ] 
	then
		#cancel the first rec
		newRec=0
		#get the rec type
		RecType=`echo $line | cut -c51-53`
		echo "New Line $lineCount"
	fi

	echo "$lineCount|$RecType|$line" >> file1.txt
	
		
	#get the first column to test against 8 (the end of batch indicator)
	fc=`echo $line | cut -c1`

	if [ $fc = 8 ] 
	then
		newRec=1
	fi
#done
done < test_file.txt

`chmod 766 file1.txt`

You want to make a file with line numbers and a copy of the rectype on the left? Something using sed/awk/PERL might be more competent and simpler (too many shell outs are slow, too).

sed '
  s/^.\{50\)\(...\)/\1\
&/
  :loop
  s/\(...\)\n\(.*\)/|\1|\2\
\1/
  n
  P
  $d
  N
  s/^|...|8.*\n...\(\n.\{50\}\(...\)\)/\2\1/
  s/.*\n\(.*\n\)/\1/
  b loop
 ' | sed '
  N
  s/\n//
 '

Narrative:

  1. The first sed takes record type from very first line, sticks it on a new line in front of the first line,
  2. the next line is a branch target,
  3. sed rearranges the line to your desired output line but missing the line number plus a second line retaining the record type,
  4. prints the line number (on a new output line),
  5. prints the constructed line but not the record type on the next line in the buffer,
  6. if at EOF, exits cleaning the buffer
  7. gets the next line as second line in the buffer,
  8. captures any new record type if last was an 8 record,
  9. deletes the first line in the buffer if there are still 3,
  10. returns to the the loop tag.
  11. The second sed merges the odd line with the even line following.

If you want to use parameters on your shell script, you can start with the two most important variables in it:
. input file.
. output file.

#!/bin/bash                                                 
#u Error trying to use script.
#u Usage: your_script <in_file> <out_file>
#u        Two parameters must be entered.
if [[ $# != 2 ]]; then
  sed -n '/^#u/s/..//p' your_script
fi

`rm $2`
lineCount=0
newRec=1

IFS=`echo "\n\c"`
while read line
do

	lineCount=$(($lineCount + 1))
	
	#check is it a newRec, it was default to 1
	if [ $newRec = 1 ] 
	then
		#cancel the first rec
		newRec=0
		#get the rec type
		RecType=`echo $line | cut -c51-53`
		echo "New Line $lineCount"
	fi

	echo "$lineCount|$RecType|$line" >> $2	
		
	#get the first column to test against 8 (the end of batch indicator)
	fc=`echo $line | cut -c1`

	if [ $fc = 8 ] 
	then
		newRec=1
	fi
#done
done < $1

`chmod 766 $2`