From 1f29d01694a293685feacd7abb4a2639e5cbcc6f Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:05:19 -0700 Subject: [PATCH] Remove leading and trailing whitespace and `.` characters and duplicate `.` characters as each list is stored. Should fix #32. --- gravity.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 934581e8..3dc9b8df 100755 --- a/gravity.sh +++ b/gravity.sh @@ -69,7 +69,8 @@ do # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation + echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ + sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation else echo "Skipping $domain list because it does not have any new entries..." fi