From 563db80b6d6867b922783e13dda57198e5d29304 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Fri, 17 Jul 2015 20:49:03 -0500 Subject: [PATCH] resolves #25 Will not count blank lines if they happen to exist. --- gravity.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 919ebac9..f4ef9d9c 100755 --- a/gravity.sh +++ b/gravity.sh @@ -80,7 +80,7 @@ find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\ # Append blacklist entries if they exist if [[ -f $blacklist ]];then - numberOf=$(cat $blacklist | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) echo "** Blacklisting $numberOf domain(s)..." cat $blacklist >> $origin/$matter else @@ -90,13 +90,13 @@ fi function gravity_advanced() ########################### { - numberOf=$(cat $origin/$andLight | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $origin/$andLight | sed '/^\s*$/d' | wc -l) echo "** $numberOf domains being pulled in by gravity..." # Remove carriage returns and preceding whitespace cat $origin/$andLight | sed $'s/\r$//' | sed '/^\s*$/d' > $origin/$supernova # Sort and remove duplicates cat $origin/$supernova | sort | uniq > $origin/$eventHorizon - numberOf=$(cat $origin/$eventHorizon | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $origin/$eventHorizon | sed '/^\s*$/d' | wc -l) echo "** $numberOf unique domains trapped in the event horizon." # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." @@ -114,7 +114,7 @@ function gravity_advanced() # Whitelist (if applicable) then remove duplicates and format for dnsmasq if [[ -f $whitelist ]];then # Remove whitelist entries - numberOf=$(cat $whitelist | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) echo "** Whitelisting $numberOf domain(s)..." # Append a "$" to the end of each line so it can be parsed out with grep -w echo -n "^$" > $latentWhitelist