You did not explain whether or not you get a new file each day (which is what I assume) or if you are appending to an existing file. Using the awk solution will only increment from 1 to the number of records in the file. Thus, each day your sequence number will start with 1 and end with the number of the last record if the file you are getting is a new file. Also, it will not keep track of the last number used.
Look at the . notation for your last sequence number. You could create a file with a variable that contains the last sequence number used and source it in at the start of your script. If you called your script myCounter.ksh, you could source it into your script as follows:
. ./myCounter.ksh
At the end of your script, you could rewrite the myCounter.ksh script from the script you use to imcrement the record and rewrite it.
Your logic would be:
. ./myCounter.ksh
read in each record
loop
increment the Counter variable by some number
read in a record
write your counter variable and record to a file
end loop
rewrite your myCounter.ksh script with the last number used.
Your myCounter.ksh script needs to contain nothing more than a variable. It could look like this the first time:
Counter=0
if you had 50 records the first day, the value of Counter would be 50. You could then use a print statement like:
print "Counter=${Counter_variable}" > myCounter.ksh
This would recreate the myCounter.ksh script with the last value used following execution of the script.
The script you want to write is fairly simple. Look at the exec, read, and print commands. If you need help, send me an email.
Jerry