0

I have two host file list like this:

file1.hosts

0.0.0.0 site1.com
0.0.0.0 site2.com

file2.hosts

0.0.0.0 site1.com
0.0.0.0 site3.com

Now I want one list that looks like this:

hosts.hosts

0.0.0.0 site1.com
0.0.0.0 site2.com
0.0.0.0 site3.com

What is the best way to get this? I tried it with join but I don't get it to work.

2

You could use sort instead. The -u-Option supressed duplicates in the output:

$ sort -u file*.hosts | tee hosts.hosts
0.0.0.0 site1.com
0.0.0.0 site2.com
0.0.0.0 site3.com

Note that I'm using tee so that we get to see the output while creating the file.

You could just as well just use redirection instead:

$ sort -u file*.hosts > hosts.hosts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.