如何從文件中刪除多個標題?我從How can I delete duplicate lines in a file in Unix?找到後嘗試使用下面的代碼。有沒有辦法在Unix中的文件中刪除重複的頭文件?
awk '!x[$0]++' file.txt
它正在刪除文件中的所有重複記錄。但在我的情況下,我只需要刪除頭部重複項,而不是文件中的重複記錄。例如,我有以下數據的文件:
column1, column2, column3, column4, column5
value11, value12, value13, value14, value14
value21, value22, value23, value24, value25
value31, value32, value33, value34, value35
value41, value42, value43, value44, value45
value51, value52, value53, value54, value55
value21, value22, value23, value24, value25
column1, column2, column3, column4, column5
value11, value12, value13, value14, value14
value21, value22, value23, value24, value25
column1, column2, column3, column4, column5
column1, column2, column3, column4, column5
我期待輸出如下:
column1, column2, column3, column4, column5
value11, value12, value13, value14, value14
value21, value22, value23, value24, value25
value31, value32, value33, value34, value35
value41, value42, value43, value44, value45
value51, value52, value53, value54, value55
value21, value22, value23, value24, value25
value11, value12, value13, value14, value14
value21, value22, value23, value24, value25
'$ 0 == {頭旁邊} 1'可以寫成只是'$ 0 = header'! –