I have two host file list like this:

file1.hosts site1.com site2.com

file2.hosts site1.com site3.com

Now I want one list that looks like this:

hosts.hosts site1.com site2.com site3.com

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


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

$ sort -u file*.hosts | tee hosts.hosts site1.com site2.com 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.