I have a file in Unix like the follows
">hello"
"hello"
"newuser"
"<newuser"
"newone"
Now I want to find unique occurrences in the file (exluding the < or > only while searching) and the output as:
">hello"
"<newuser"
"newone"
Here's that associative array idea in Ruby.
2.0.0p195 :005 > entries= [">hello", "hello", "newuser", "<newuser", "newone"]
=> [">hello", "hello", "newuser", "<newuser", "newone"]
2.0.0p195 :006 > entries.reduce({}) { |hash, entry| hash[entry.sub(/[<>]/,'')]=entry; hash}.values
=> ["hello", "<newuser", "newone"]
man uniqat your terminal?