LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   uniq (https://www.linuxquestions.org/questions/linux-general-1/uniq-46129/)

Cyth 02-19-2003 08:35 AM

uniq
 
Hi all,

I have a small shell parsing problem:

I have two strings(or I can concatenate them if you like) which in which I only want the unique words.
I tried piping them to uniq -u(only output unique) but that didn't work since uniq sort one lines, not words.

Any idea how to solve this? Perhaps there's a way to convert the string so the words are separeted by lines instead?

Any ideas are appreciated,

cheers,
Frans

crabboy 02-19-2003 09:22 AM

If you dont care about the order you can do this:
Code:

#!/bin/sh

cat $1 | tr [:blank:] '\012' | sort -u


Cyth 02-19-2003 09:29 AM

Thank You!


All times are GMT -5. The time now is 01:38 AM.