有没有办法根据字段过滤文件中只出现一次的行?

Is there a way to filter a file for lines that only occur once, based on a field?

我有一个 "diff like" 文件,其中字段由制表符分隔。有没有办法只使用标准的 gnu 工具只获取出现一次的行,如果它们的第二个字段相等,则两条线相等?

本质上,我只想过滤此文件的新行和删除行,而不是编辑行。

文件首先按第二列(名称)排序,然后按第一列排序(先减后加)。

<   Chandler Hutchison  Chicago Bulls   Wed, Oct 30, 2019   Out (Hamstring) - The Bulls have listed Hutchison as OUT for Wednesday's (Oct. 30) game against the Cavs.
>   Chandler Hutchison  Chicago Bulls   Thu, Oct 31, 2019   Out (Hamstring) - The Bulls have listed Hutchison as OUT for Friday's (Nov. 1) game.
>   Daniel Theis    Boston Celtics  Thu, Oct 31, 2019   Day To Day (Left Ankle) - Boston Celtics F-C Daniel Theis is probable for Friday's (Nov. 1) game against New York right a left ankle sprain.
<   Edmond Sumner   Indiana Pacers  Wed, Oct 30, 2019   Day To Day (Hand) - Sumner is OUT for Wednesday's game (Oct. 30) against the Nets.
>   Edmond Sumner   Indiana Pacers  Thu, Oct 31, 2019   Out (Hand) - Sumner will miss at least three weeks with a non-displaced fracture in his right hand.
<   Elfrid Payton   New York Knicks Wed, Oct 30, 2019   Day To Day (Hamstring) - The Knicks have listed Payton Jr. as OUT for Wednesday's game (Oct. 30) against the Magic.
>   Elfrid Payton   New York Knicks Thu, Oct 31, 2019   Day To Day (Hamstring) - Payton is listed as out for Friday's (Nov. 1) game against Boston.
<   Enes Kanter Boston Celtics  Wed, Oct 30, 2019   Day To Day (Left Knee) - The Celtics have listed Kanter as OUT for Wednesday's game (Oct. 30) against the Bucks.
>   Enes Kanter Boston Celtics  Thu, Oct 31, 2019   Day To Day (Left Knee) - The Celtics have listed Kanter as OUT for Friday's game (Nov. 1) against New York.
<   Evan Turner Atlanta Hawks   Wed, Oct 30, 2019   Day To Day (Achilles) - Turner is listed as doubtful for Thursday's (Oct. 31) game.
>   Evan Turner Atlanta Hawks   Thu, Oct 31, 2019   Out (Achilles) - Turner is listed as OUT for Thursday's (Oct. 31) game.
>   Frank Ntilikina New York Knicks Thu, Oct 31, 2019   Day To Day (Neck) - Ntilikina is listed as probable for Friday's (Nov. 1) game.
<   Harry Giles Sacramento Kings    Wed, Oct 30, 2019   Day To Day (Knee) - Giles III was inactive for Wednesday's game (Oct. 30) against the Hornets.
>   Harry Giles Sacramento Kings    Thu, Oct 31, 2019   Day To Day (Knee) - Giles III is listed as questionable for Friday's (Nov. 1) game.
<   Jaylen Brown    Boston Celtics  Wed, Oct 30, 2019   Day To Day (Illness) - Brown is listed as OUT for Wednesday's (Oct. 30) game against the Bucks.
>   Jaylen Brown    Boston Celtics  Thu, Oct 31, 2019   Day To Day (Illness) - Brown is listed as questionable for Friday's (Nov. 1) game against New York.
>   Justise Winslow Miami Heat  Thu, Oct 31, 2019   Out (Lower Back) - Miami Heat F Justise Winslow is OUT for Thursday's (Oct. 31) game against Atlanta with lower back stiffness.
>   Kawhi Leonard   Los Angeles Clippers    Thu, Oct 31, 2019   Out (Load Management) - Los Angeles Clippers F Kawhi Leonard is out for Thursday's (Oct. 31) against San Antonio.
>   Kyle Korver Milwaukee Bucks Thu, Oct 31, 2019   Out (Rest) - Korver is listed as OUT for Friday's (Nov. 1) game.
>   Matthew Dellavedova Cleveland Cavaliers Thu, Oct 31, 2019   Out (Personal) - Dellavedova is listed as OUT for Friday's (Nov. 1) game.
<   Myles Turner    Indiana Pacers  Wed, Oct 30, 2019   Day To Day (Sprained Right Ankle) - Turner left Wednesday's (October 30) game with a sprained right ankle.
>   Myles Turner    Indiana Pacers  Thu, Oct 31, 2019   Out (Sprained Right Ankle) - Turner is week-to-week with a sprained right ankle.
<   Rajon Rondo Los Angeles Lakers  Tue, Oct 29, 2019   Day To Day (Calf) - Rondo did not play in Tuesday's game (Oct. 29) against the Grizzlies.
>   Rajon Rondo Los Angeles Lakers  Thu, Oct 31, 2019   Day To Day (Calf) - Rondo is listed as out for Friday's (Nov. 1) game against Dallas.
<   Sekou Doumbouya Detroit Pistons Wed, Oct 30, 2019   Day To Day (Concussion) - The Pistons have listed Doumbouya as OUT for Wednesday's game (Oct. 30) against the Raptors.
>   Sekou Doumbouya Detroit Pistons Thu, Oct 31, 2019   Out (Concussion) - The Pistons have listed Doumbouya as OUT for Friday's (Nov. 1) game.
>   Will Barton Denver Nuggets  Thu, Oct 31, 2019   Out (Left Toe) - Denver Nuggets G Will Barton is OUT for Thursday's (Oct. 31) game against New Orleans with left toe inflammation.

经过一些 awk 的争论,我想到了这个。 它计算第二个字段的所有出现次数,然后打印那些等于 1 的次数。

awk -F $'\t' '{count[]++} count[] == 1'