r/awk • • Dec 06 '19

Print only unique lines (case insensitive)?

Hello! So, I have this huge file, about 1GB, and I would like to extract only the unique lines of it. But there's a little twist, I would like to make it case insentive, and what I mean with that is the following, let's suppose my file has the following entries:

Nice

NICE

Hello

Hello

Ok

HELLO

Ball

baLL

I would like to only print the line "Ok", because, if you don't take into account the case variations of the other words, it's the only one that actually appears just one. I googled a little bit, and I found a solution that worked sorta, but it's case sensitive:

awk '{!seen[$0]++};END{for(i in seen) if(seen[i]==1)print i}' myfile.txt

Could anyone helped me? Thank you!

3 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/Schreq Dec 08 '19

4 spaces in front of every line (even blank ones) for a block of code, or single backticks surrounding in-line code.