merge-hosts (294B)
1 #!/usr/bin/env sh 2 3 hostdir="/etc/hosts.d" 4 hostfile="/etc/hosts" 5 6 [ $(id -u ) -ne 0 ] && printf "Please run as root.\n" && exit 1 7 [ -e "$hostfile" ] && cp "$hostfile" "$hostfile.bak" 8 9 :> "${hostfile}" 10 for file in "$hostdir/"* ; do 11 cat "$file" >> "$hostfile" 12 done 13 14 printf "Created $hostfile.\n"