user8193740
user8193740

Reputation:

get unique values, out of a list with uniq utility, when data are separated by |

I have a list of values, that may have in them special characters, all kind of characters.

[email protected]
Denver Occupy|another name|metadata
another name
metadata

I need a way with uniq utility in linux, or sed, awk, to have as output: unique values from above list:

[email protected]
Denver Occupy
another name
metadata

What i have tried:

uniq -u test

Upvotes: 1

Views: 228

Answers (2)

Mmmonster
Mmmonster

Reputation: 1

sed -ne "s/|/\n/p" test |sort |uniq

enjoy

Upvotes: 0

Nahuel Fouilleul
Nahuel Fouilleul

Reputation: 19315

uniq will work only if repeated lines are adjacent

will give uniq values sorted

sort -u test

EDIT: to split lines on |

tr '|' '\n' < test | sort -u

Upvotes: 1

Related Questions