Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit f5877e2

Browse files
improved example for multiple field duplicate detection
1 parent 6aeebc7 commit f5877e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gnu_awk.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,9 +1712,10 @@ $ awk -M '!($2 in seen){c++} {seen[$2]} END{print +c}' duplicates.txt
17121712

17131713
* For multiple fields, separate them using `,` or form a string with some character in between
17141714
* choose a character unlikely to appear in input data, else there can be false matches
1715+
* `FS` is a good choice as fields wouldn't contain separator character(s)
17151716

17161717
```bash
1717-
$ awk '!seen[$2"_"$3]++' duplicates.txt
1718+
$ awk '!seen[$2 FS $3]++' duplicates.txt
17181719
abc 7 4
17191720
food toy ****
17201721
test toy 123

0 commit comments

Comments
 (0)