Would like to print all the minimum values based on $1 and $3 combinations. If there are two or more lines are available for minimum value having unique combinations of $1 and $3 then need to print all the lines . For example , $1-"Abc" having minimum value $3-"10" appearing two times i.e Abc,yyy,10,aaa and Abc,ttt,10,aaa. Input file has not sorted on any order.
Input.txt
Country,Desc,Amount,Details
Abc,xxx,20,aaa
Abc,yyy,10,aaa
ghi,ttt,25,ccc
Abc,zzz,35,aaa
def,xxx,30,bbb
Abc,ttt,10,aaa
def,yyy,20,bbb
ghi,yyy,25,ccc
def,zzz,45,bbb
ghi,xxx,35,ccc
ghi,zzz,50,ccc
Would like to print the output along with header row NR==1 , {print}
Desired Output.txt
Country,Desc,Amount,Details
Abc,yyy,10,aaa
Abc,ttt,10,aaa
ghi,ttt,25,ccc
ghi,yyy,25,ccc
def,yyy,20,bbb
I am using two commands to get the desired output, first sort the input file based on $1 and $3 then second command awk -F, '!seen[$1]++'
Looking for your suggestions to simply like one liner.