How to redirect records to different output files based on a value in one of the columns in a file using nawk/awk?..
chethan RA
Ramesh RA
Sachin RA
Gundaa DI
dravid DI
Suresh SE
So I want to redirect RA records to one file, DI records to another file and SE records to another file. Value in Second column can be anything need not be RA, DI or SE. So based on different values in second column, records need to be redirected to different files..
You could try something like this:
Consider that some awk implementations can open a limited number of files at a time.
If that’s the case you’ll need more code, something like this:
[corrected, see comments below]
The latter will be far less efficient.