I have a file test.txt contains:
xyz[4.7],default,
xyz[4.3],default,
xyz[4.4],default,
xyz[4.6],default,
harry[1.0],default,
molly[1.1],default,
abc[1.4],rome,
abc[1.2],rome,
abc[1.1],rome,
abc[1.0],rome,
ghi[1.0],moon,
so am trying to place the latest 3 versions in latest.txt and rest of the them into old.txt
am using the below command
awk '{out=a[$1]++ > 2 ? "./temp/old.txt" : "./temp/latest.txt"; print > out}' FS=[
My requirement is the versions am keping as a input variable. lets say some times i need only 2 latest versions sometimes it may be 4
in the above command am making latest 3versions..am hardcoding the variable with "2" in the command.i need it as a variable
Thanks in Advance