Forum Moderators: bakedjake

Message Too Old, No Replies

using command "comm"

how to compare two files and create a third one?

         

Montbazin

10:24 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



hello

There is this beautiful command :

comm file1 file2

I would like to make a little script where I can enter the result in a third file
file3

Any idea how this can be done?
thanx a lot...

MattyMoose

10:50 pm on Jun 1, 2005 (gmt 0)

10+ Year Member




comm file1 file2 > file3

Is that what you're looking for? It redirects the output of the comm file1 file2 command to file3.

It's probably stickier than thatbut from a quick test, it seemed to work for me. :)

MM

Montbazin

9:57 am on Jun 2, 2005 (gmt 0)

10+ Year Member



thanx a lot
that works fine
sorry, but I'm just a beginner...

MattyMoose

3:52 pm on Jun 2, 2005 (gmt 0)

10+ Year Member



You're welcome, and welcome to the Unix world, where there is so much to learn everyday, it's a thrill, even after all these years. ;)

The shell is an incredibly useful tool, from stringing together multiple files quickly, to searching for an IP address in your logs, and cutting out everything except the first column, sorting numerically, and only showing the unique results.(1) Most shells have a "reason" why people use them. There are many different varieties, include sh, csh, zsh, bash, etc etc. Most people tend to gravitate toward csh,sh and bash.

Have a look at [howtos.linux.com...] for more information on redirection and pipes, and that howto in general will help quite a bit, I'm sure.

(1): I mention this one because it's a good example of a "one-liner" that takes many commands and works with a changing set of data. Here is the one-liner:


cat /path/to/apache.log ¦ cut -d- -f1 ¦ sort ¦ uniq

Neat, hey? I love *NIX. ;)

MM