From c97cfde9f991a9ddebb920d17ce015ef9f1f612f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 21 Nov 2016 22:51:59 +0000 Subject: [PATCH 1/3] Update gravity.sh Only include domain part of lines that contain `/` e.g `www.fakenewswatch.com/megynkelly` --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index d05dddea..d9bd0521 100755 --- a/gravity.sh +++ b/gravity.sh @@ -289,7 +289,7 @@ gravity_advanced() { #awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterAndLight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} #Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment') #Add additional awk command to read all lines up to a '#', and then continue as we were - cat ${piholeDir}/${matterAndLight} | awk -F'#' '{print $1}' | awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} + cat ${piholeDir}/${matterAndLight} | awk -F'#' '{print $1}' | awk -F'/' '{print $1}' | awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} echo " done!" numberOf=$(wc -l < ${piholeDir}/${supernova}) From c9fe62a691a6e5bd0b60d48865c801f90eefa422 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 1 Dec 2016 13:53:40 -0800 Subject: [PATCH 2/3] Clarify what the command is doing. Signed-off-by: Dan Schaper --- gravity.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index d9bd0521..3f73b524 100755 --- a/gravity.sh +++ b/gravity.sh @@ -288,8 +288,14 @@ gravity_advanced() { echo -n "::: Formatting list of domains to remove comments...." #awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterAndLight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} #Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment') - #Add additional awk command to read all lines up to a '#', and then continue as we were - cat ${piholeDir}/${matterAndLight} | awk -F'#' '{print $1}' | awk -F'/' '{print $1}' | awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} + #Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only. + #Last awk command takes non-commented lines and if they have 2 fields, take the left field (the domain) and leave + #+ and leave the right (IP address), otherwise grab the single field. + cat ${piholeDir}/${matterAndLight} | \ + awk -F '#' '{print $1}' | \ + awk -F '/' '{print $1}' | \ + awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | \ + sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} echo " done!" numberOf=$(wc -l < ${piholeDir}/${supernova}) From d92646324cd5ca370ce6e714c00f114ae77ae03d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 1 Dec 2016 13:59:58 -0800 Subject: [PATCH 3/3] Double worded Signed-off-by: Dan Schaper --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 3f73b524..bfe82dce 100755 --- a/gravity.sh +++ b/gravity.sh @@ -290,7 +290,7 @@ gravity_advanced() { #Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment') #Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only. #Last awk command takes non-commented lines and if they have 2 fields, take the left field (the domain) and leave - #+ and leave the right (IP address), otherwise grab the single field. + #+ the right (IP address), otherwise grab the single field. cat ${piholeDir}/${matterAndLight} | \ awk -F '#' '{print $1}' | \ awk -F '/' '{print $1}' | \