Timeline for How to remove duplicate lines with awk whilst keeping all empty lines?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 1, 2024 at 12:25 | comment | added | Amazon Dies In Darkness | According to "terdon" and "Ed Morton" this is not more efficient than the top voted answer. Neither explained why, however. Hopefully they will explain further. | |
| May 24, 2022 at 11:16 | comment | added | AdminBee |
Or, shorter '!($0 in a) {if (NF) a[$0]; print}'. - more readably: !($0 in a) {if (NF) {a[$0]}; print}'. By ensuring the $0 is only stored if the line is non-empty, ($0 in a) will always be false for empty lines.
|
|
| Nov 6, 2015 at 1:38 | history | edited | cuonglm | CC BY-SA 3.0 |
added 1 character in body
|
| Nov 5, 2015 at 20:24 | comment | added | Serge Stroobandt | I did not measure any significant time difference with my 288-line test file. However, your code certainly catches the prize for being the most readable. | |
| May 21, 2014 at 6:37 | history | answered | cuonglm | CC BY-SA 3.0 |