From 7b15a88dc45e4bda8e52a9ed6c64c1c7c44a9882 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 31 Mar 2020 18:36:40 +0000 Subject: [PATCH] Strip comments from downloaded lists instead of discarding lines with comments altogether Signed-off-by: DL6ER --- gravity.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index c421e832..2afbb17b 100755 --- a/gravity.sh +++ b/gravity.sh @@ -566,12 +566,14 @@ gravity_ParseFileIntoDomains() { # It also helps with debugging so each stage of the script can be researched more in depth # 1) Remove carriage returns # 2) Convert all characters to lowercase - # 3) Remove lines containing "#" or "/" - # 4) Remove leading tabs, spaces, etc. - # 5) Delete lines not matching domain names + # 3) Remove comments (text starting with "#", include possible spaces before the hash sign) + # 4) Remove lines containing "/" + # 5) Remove leading tabs, spaces, etc. + # 6) Delete lines not matching domain names < "${source}" tr -d '\r' | \ tr '[:upper:]' '[:lower:]' | \ - sed -r '/(\/|#).*$/d' | \ + sed 's/\s*#.*//g' | \ + sed -r '/(\/).*$/d' | \ sed -r 's/^.*\s+//g' | \ sed -r '/([^\.]+\.)+[^\.]{2,}/!d' > "${destination}" chmod 644 "${destination}"