LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-19-2003, 08:35 AM   #1
Cyth
Member
 
Registered: Mar 2001
Location: Sweden, Lund
Distribution: Slackware
Posts: 68

Rep: Reputation: 15
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
 
Old 02-19-2003, 09:22 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
If you dont care about the order you can do this:
Code:
#!/bin/sh

cat $1 | tr [:blank:] '\012' | sort -u
 
Old 02-19-2003, 09:29 AM   #3
Cyth
Member
 
Registered: Mar 2001
Location: Sweden, Lund
Distribution: Slackware
Posts: 68

Original Poster
Rep: Reputation: 15
Thank You!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
uniq in tcl/tk liguorir Linux - Software 1 05-20-2004 10:34 PM
Catch-22 with 'uniq' - sed, awk, another way out? slakmagik Linux - General 5 07-31-2003 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration