我想读fileIn.txt(逗号分隔)和仅匹配第一3个不同的值的行输出fileOut.txt给定的列。例如,我的输入文件看起来像这样:AWK:基于给定列的第一个3个不同的值选择行
fileIn.txt
#location,day,time
home,mon,01:00
office,mon,06:00
home,mon,10:00
office,tues,03:00
home,wed,08:00
home,wed,11:00
home,thurs,02:00
home,fri,01:00
diner,fri,07:00
party,fri,09:00
home,sat,02:00
mall,sat,06:00
home,sat,09:00
beach,sun,01:00
我只需要选择与第3种不同的天行,让自己的输出文件看起来像这样:
fileOut.txt
#location,day,time
home,mon,01:00
office,mon,06:00
home,mon,10:00
office,tues,03:00
home,wed,08:00
home,wed,11:00
可以假定输入文件已经排序了吗? – Jeff
是的,你可以这样认为。 – amatek