Not completely sure about your whole requirement, could you please change pth/"tgt_file_name"CURR_DATE"_"NR%10 to following into your code and let me know how it goes please.
One more query, there will be around 10 million records in source file, that must be distributed/split exactly in 10 files. Since i have used awk print >> . Do i need to close it also. ?
Thanks
Yes, you could do division by int(NR/1000000) to make only 10 files as per your requirement. You could double check it as I don't have 10 million line Input_file with me, so logic is simple like if you wanted to make 10 files just divide the total number of lines by the number of files which you need and you will get per file total number of lines then.
Yes, we do need to close the files for example close(f) where f is a variable for the filename.
I hope this helps you.
The NR%10 will distribute the lines as evenly as possible between 10 files, writing every single line to the next (rotating) file, independent of the total number of lines.
If the open file count is less then the max. allowed open files, close(f) is not indispensable, although it were good style - normally. In your case of 1E7 lines, it would mean 1E7 open and 1E7 close operations, slowing down processing considerably. Me, I'd forgo it.