mirror of
https://github.com/columndeeply/hosts.git
synced 2025-10-28 12:01:08 -04:00
Add sed command to remove all domains not containing a dot (should get rid of all invalid domains)
This commit is contained in:
@ -19,6 +19,8 @@ for file in "$@"; do
|
|||||||
sed -i -r 's/^([0-9]{1,3}\.){3}[0-9]{1,3} /127.0.0.1 /g' "$file"
|
sed -i -r 's/^([0-9]{1,3}\.){3}[0-9]{1,3} /127.0.0.1 /g' "$file"
|
||||||
## Remove any lines pointing to an IP address, hosts file only works with domains or hostnames
|
## Remove any lines pointing to an IP address, hosts file only works with domains or hostnames
|
||||||
sed -i -r '/ ([0-9]{1,3}\.){3}[0-9]{1,3}$/d' "$file"
|
sed -i -r '/ ([0-9]{1,3}\.){3}[0-9]{1,3}$/d' "$file"
|
||||||
|
## Remove any lines that don't have a dot after the 127.0.0.1
|
||||||
|
sed -i '/127\.0\.0\.1 [^ ]*\.[^ ]*/!d' "$file"
|
||||||
|
|
||||||
# Remove multiple spaces and return lines (If anybody knows how to do this with sed please let me know)
|
# Remove multiple spaces and return lines (If anybody knows how to do this with sed please let me know)
|
||||||
tr -s ' ' < "$file" | tr -d '\r' > "$file.tmp"
|
tr -s ' ' < "$file" | tr -d '\r' > "$file.tmp"
|
||||||
|
|||||||
Reference in New Issue
Block a user