unnknown
unnknown

Reputation: 1785

Union of file contents?

I'm trying to merge a whole bunch of files together. Most of the files will have the same data on each line. How can I merge them all together in one file so that the result is the union of all the lines of all the files?

What is a utility that can easily do this? Or some other quick way?

I use Windows.

Thanks!

Upvotes: 0

Views: 89

Answers (1)

Steve
Steve

Reputation: 7128

If you just need to combine them, the. copy command should be able to do that.

copy *.txt combo.txt

You might also be able to use the type command.

type *.txt > combo.txt

If you need the combined file sorted, there's a command for that, too.

But when you say "union," it makes me think that you want to remove duplicates. I don't know how to do that in pure Windows, but standard Unix utilities were born for this stuff. If you were to install Cygwin, you could use those utilities for this kind of text manipulation without leaving Windows. The command would look something like this:

cat *.txt | sort -u > combo.txt

Upvotes: 2

Related Questions