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 -u
doesn't report the unique line but the first in lines sort the same in current locale. – cuonglm Jun 11 '15 at 08:43①@example.com
and②@example.com
inen_US.utf8
locale. – cuonglm Jun 11 '15 at 09:18LC_ALL=en_US.UTF-8; (echo ①@example.com; echo ②@example.com) | sort | uniq
also merges both lines, so only theawk
solution 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:18awk
can't manipulate files in that way. You can combineawk
withsponge
(frommoreutils
) to re-write the input file. – Stephen Kitt Jan 08 '16 at 08:23