Insert text at end of the hosts file from another text file

I would like to be able to insert the contents of a text file at the end of the host file.

I need that because my hosts file is frequently updated.

How can I do that?


How about this?

cat [the other text file] >> /etc/hosts

If your shell doesn't run as a privileged user, you can try:

sudo bash -c 'cat [the other text file] >> /etc/hosts'
1 Like