Hi Code gurus!!...my first post in this forums and I m new to shell scripting too!...I need a shell script to accomplish the below, any input will be greatly appreciated..
Below is a sample content of a text file, file1.txt
AMPS,2324,Subscriber,Unknown,SingleDay,20070413,20070413,
ALPEnt,4516,AllMember,Unknown,DateRange,20070411,20070419,
AGLT,2156,Summary,Unknown,
DUPP,2536,Yes,Unknown,
My current UNIX script reads the file (file1.txt) line by line- each line calls various scripts (to generate reports) depending on the first parameter that is passed. These text files can sometime reach as many as 50 lines (meaning 50 reports have to be generated). Sometimes the process cannot complete. Let us say, for example, the process fails on line 22 (meaning 21 reports were generated and another 29 were not). When I restart the shell script, I want it to be able to start from line 22 and not from the beginning. One solution is to copy each line for which the report is generated, to a temp file (file1_temp.tmp). If the process fails in between, the script does a count on the number of lines present in temp file (file1_temp.tmp) and then continues to generate report from file1.txt based on the count obtained.
I need a script to accomplish the following:
1) Create a file: file1_temp.tmp
2) Do a count on number of lines in file1_temp.tmp
3) Start reading the line number obtained in step 2 from original file, file1.txt and generate reports (initially the count will be zero and hence will read file from the first line)
4) Once the report is complete, copy the line from file1.txt to file1_temp.tmp
5) Once the whole file is processed, delete both, file.txt and file1_temp.tmp
PLEASE HELP ME OUT HERE!
Thanks!