mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-25 15:43:19 +00:00
Unifiy sed commands
Co-authored-by: RD WebDesign <github@rdwebdesign.com.br> Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
56eae4afbe
commit
61ff5b2c76
1 changed files with 14 additions and 18 deletions
32
gravity.sh
32
gravity.sh
|
@ -768,25 +768,21 @@ gravity_ParseFileIntoDomains() {
|
||||||
tr '[:upper:]' '[:lower:]' < "${src}" > "${destination}"
|
tr '[:upper:]' '[:lower:]' < "${src}" > "${destination}"
|
||||||
|
|
||||||
# 2) Remove carriage returns
|
# 2) Remove carriage returns
|
||||||
sed -i 's/\r$//' "${destination}"
|
# 3) Remove comments (text starting with "#", include possible spaces before the hash sign)
|
||||||
|
# 4) Remove lines starting with ! (ABP Comments)
|
||||||
|
# 5) Remove lines starting with [ (ABP Header)
|
||||||
|
# 6) Remove lines containing "/"
|
||||||
|
# 7) Remove leading tabs, spaces, etc. (Also removes leading IP addresses)
|
||||||
|
# 8) Remove empty lines
|
||||||
|
|
||||||
# 3a) Remove comments (text starting with "#", include possible spaces before the hash sign)
|
sed -i -r \
|
||||||
sed -i 's/\s*#.*//g' "${destination}"
|
-e 's/\r$//' \
|
||||||
|
-e 's/\s*#.*//g' \
|
||||||
# 3b) Remove lines starting with ! (ABP Comments)
|
-e 's/\s*!.*//g' \
|
||||||
sed -i 's/\s*!.*//g' "${destination}"
|
-e 's/\s*\[.*//g' \
|
||||||
|
-e '/(\/).*$/d' \
|
||||||
# 3c) Remove lines starting with [ (ABP Header)
|
-e 's/^.*\s+//g' \
|
||||||
sed -i 's/\s*\[.*//g' "${destination}"
|
-e '/^$/d' "${destination}"
|
||||||
|
|
||||||
# 4) Remove lines containing "/"
|
|
||||||
sed -i -r '/(\/).*$/d' "${destination}"
|
|
||||||
|
|
||||||
# 5) Remove leading tabs, spaces, etc. (Also removes leading IP addresses)
|
|
||||||
sed -i -r 's/^.*\s+//g' "${destination}"
|
|
||||||
|
|
||||||
# 6) Remove empty lines
|
|
||||||
sed -i '/^$/d' "${destination}"
|
|
||||||
|
|
||||||
chmod 644 "${destination}"
|
chmod 644 "${destination}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue