user614573
user614573

Reputation: 21

Remove duplicate entries in a file without sed, awk, or uniq

Is there a way to remove duplicate entries in a file without sed, awk, or uniq?

Upvotes: 2

Views: 1163

Answers (2)

sarnold
sarnold

Reputation: 104050

Even though this is a bit silly, it sounded fun. Here's my first attempt:

cat -n /etc/passwd /etc/passwd | sort -u -k 2 | sort -n | cut -b8-

Duplicates should be gone and the file should be in the original output order.

Upvotes: 2

bdonlan
bdonlan

Reputation: 231103

Use Perl.

If you don't mind line numbers changing, sort -u (GNU systems only)

Upvotes: 2

Related Questions