#!/bin/bash update_ip_address() { file=/etc/hosts if [[ $(grep $1 $file) ]]; then IP=$(nslookup -query=A $1 8.8.8.8 | grep 'Address:' | tail -1 | \ grep -oE '((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]))') sed -i "/$1/ s/.*/$IP\t$1/g" $file fi } update_ip_address restrict.youtube.com update_ip_address restrictmoderate.youtube.com update_ip_address strict.bing.com update_ip_address forcesafesearch.google.com update_ip_address safe.duckduckgo.com