mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Remove unneeded ifs in awk
Signed-off-by: Riley Avron <riley.avron@gmail.com>
This commit is contained in:
parent
aed20cf7c6
commit
512ec7fb87
13
gravity.sh
13
gravity.sh
@ -345,13 +345,14 @@ gravity_ParseFileIntoDomains() {
|
|||||||
# Scanning for "^IPv4$" is too slow with large (1M) lists on low-end hardware
|
# Scanning for "^IPv4$" is too slow with large (1M) lists on low-end hardware
|
||||||
echo -ne " ${INFO} Format: URL"
|
echo -ne " ${INFO} Format: URL"
|
||||||
|
|
||||||
awk '{
|
awk '
|
||||||
# Remove URL protocol, optional "username:password@", and ":?/;"
|
# Remove URL protocol, optional "username:password@", and ":?/;"
|
||||||
if ($0 ~ /[:?\/;]/) { gsub(/(^.*:\/\/(.*:.*@)?|[:?\/;].*)/, "", $0) }
|
/[:?\/;]/ { gsub(/(^.*:\/\/(.*:.*@)?|[:?\/;].*)/, "", $0) }
|
||||||
# Remove lines which are only IPv4 addresses
|
# Skip lines which are only IPv4 addresses
|
||||||
if ($0 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { $0="" }
|
/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ { next }
|
||||||
if ($0) { print $0 }
|
# Print if nonempty
|
||||||
}' "${source}" 2> /dev/null > "${destination}"
|
length { print $0 }
|
||||||
|
' "${source}" 2> /dev/null > "${destination}"
|
||||||
|
|
||||||
echo -e "${OVER} ${TICK} Format: URL"
|
echo -e "${OVER} ${TICK} Format: URL"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user