You are not logged in.

#1 2010-11-05 22:36:00

gromlok
Member
Registered: 2010-04-19
Posts: 154

null

null

Last edited by gromlok (2019-03-10 15:36:24)


.

Offline

#2 2010-11-05 23:31:49

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: null

cat /etc/hosts.standard > /etc/hosts
cat /etc/hosts.tor >> /etc/hosts
cat /etc/hosts.pages >> /etc/hosts
cat /etc/hosts.X >> /etc/hosts

Maintain your separate files as hosts.<whatever> then use a script like the above to consolidate them into the actual /etc/hosts file

EDIT: Yes, the first line has ONE > symbol (that overwrites the file with the contents of hosts.standard) and the rest have TWO >> symbols (to append the other files, rather than overwrite)

Last edited by fukawi2 (2010-11-05 23:32:43)

Offline

#3 2010-11-06 01:26:37

gromlok
Member
Registered: 2010-04-19
Posts: 154

Re: null

null

Last edited by gromlok (2019-03-10 15:36:35)


.

Offline

#4 2010-11-06 06:50:20

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: null

TS=`date +%m-%d-%y %H:%M:%S`
mv /etc/host ~/myhost/backups/hosts$TS

Using a pipe ('|') in file names is a bad idea

Offline

#5 2010-11-06 10:22:55

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: null

Or you could use dnsmasq if you don't mind having another daemon running, as a bonus you get dns caching. In the configuration file you then tell it to load several separate files, all with the correct hosts file syntax.

@fukawi2
Don't you mean

TS=`date "+%m-%d-%y %H:%M:%S"`
mv /etc/host "~/myhost/backups/hosts$TS"

R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#6 2010-11-06 10:47:41

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: null

also see this

Offline

#7 2010-11-06 12:35:20

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: null

R00KIE wrote:

@fukawi2
Don't you mean

Errr, yeah... Forgot there was a space in there, thx for picking that up wink

Offline

#8 2010-11-06 14:19:36

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: null

Just to make fukawi2's script idea more manageable. i.e no matter how many host files you have.

cat /etc/hosts.* > /etc/hosts

EDIT: Damm hosts.allow and hosts.deny - You must be able to omit those somehow

Last edited by gazj (2010-11-06 14:21:24)

Offline

#9 2010-11-06 15:07:36

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: null

shopt -s extglob
cat /etc/hosts.!(allow|deny) > /etc/hosts

this is purely a bashism.

Offline

#10 2010-11-06 18:23:34

gromlok
Member
Registered: 2010-04-19
Posts: 154

Re: null

null

Last edited by gromlok (2019-03-10 15:36:46)


.

Offline

Board footer

Powered by FluxBB