I created a txt file using two requests, one LDAP and one SQL. Results of the two requests are stored in the same txt file.
The txt file looks like this :
user1@domain.fr
user2@domain.fr
user3@domain.fr
user1@domain.fr
user4@domain.fr
Because a user can be in the two databases, I need to delete duplicate entries, using bash.
How can I do it?
sort -udoesn't report the unique line but the first in lines sort the same in current locale. – cuonglm Jun 11 '15 at 08:43①@example.comand②@example.cominen_US.utf8locale. – cuonglm Jun 11 '15 at 09:18LC_ALL=en_US.UTF-8; (echo ①@example.com; echo ②@example.com) | sort | uniqalso merges both lines, so only theawksolution is viable in that case. – Stephen Kitt Jun 11 '15 at 18:23uniq -i. – cuonglm Jun 12 '15 at 01:09awk? – CodyChan Jan 08 '16 at 03:18awkcan't manipulate files in that way. You can combineawkwithsponge(frommoreutils) to re-write the input file. – Stephen Kitt Jan 08 '16 at 08:23