You're viewing a comment by Thomas Guest and its responses.

October 14, 2008, 09:43

Hi Peter. Nice article, which intersects with something I wrote last year about shell scripting, using the set operations example. It's always good to compare notes on how someone else tackles the same problem.

By the way, there's no need to start a pipeline off with cat. Instead of

$ cat set1 set2 | sort -m | uniq

edit: Thomas wrote this example and then noticed that it was not correct. He commented:
Now that I think about it

$ cat set1 set2 | sort -m

is wrong!

Sort -m only works when merging multiple sorted files together: catting the inputs into a single file is a bad idea in this case.

you could just have

$ sort -m set1 set2 | uniq

or even (with gnu sort)

$ sort -mu set1 set2

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "coding_97": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.