mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Improve output
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
8131b5961c
commit
1e8bfd33f5
1 changed files with 4 additions and 11 deletions
15
gravity.sh
15
gravity.sh
|
@ -423,26 +423,19 @@ parseList() {
|
||||||
# Find (up to) five domains containing invalid characters (see above)
|
# Find (up to) five domains containing invalid characters (see above)
|
||||||
incorrect_lines="$(sed -e "/[^a-zA-Z0-9.\_-]/!d" "${src}" | head -n 5)"
|
incorrect_lines="$(sed -e "/[^a-zA-Z0-9.\_-]/!d" "${src}" | head -n 5)"
|
||||||
|
|
||||||
local num_lines num_target_lines num_correct_lines percentage percentage_fraction
|
local num_lines num_target_lines num_correct_lines num_invalid
|
||||||
# Get number of lines in source file
|
# Get number of lines in source file
|
||||||
num_lines="$(grep -c "^" "${src}")"
|
num_lines="$(grep -c "^" "${src}")"
|
||||||
# Get number of lines in destination file
|
# Get number of lines in destination file
|
||||||
num_target_lines="$(grep -c "^" "${target}")"
|
num_target_lines="$(grep -c "^" "${target}")"
|
||||||
num_correct_lines="$(( num_target_lines-total_num ))"
|
num_correct_lines="$(( num_target_lines-total_num ))"
|
||||||
total_num="$num_target_lines"
|
total_num="$num_target_lines"
|
||||||
# Compute percentage of valid lines
|
num_invalid="$(( num_lines-num_correct_lines ))"
|
||||||
percentage=100
|
echo " ${INFO} Imported ${num_correct_lines} of ${num_lines} domains, ${num_invalid} domains invalid"
|
||||||
percentage_fraction=0
|
|
||||||
if [[ "${num_lines}" -gt 0 ]]; then
|
|
||||||
percentage="$(( 1000*num_correct_lines/num_lines ))"
|
|
||||||
percentage_fraction="$(( percentage%10 ))"
|
|
||||||
percentage="$(( percentage/10 ))"
|
|
||||||
fi
|
|
||||||
echo " ${INFO} ${num_correct_lines} of ${num_lines} domains imported (${percentage}.${percentage_fraction}%)"
|
|
||||||
|
|
||||||
# Display sample of invalid lines if we found some
|
# Display sample of invalid lines if we found some
|
||||||
if [[ -n "${incorrect_lines}" ]]; then
|
if [[ -n "${incorrect_lines}" ]]; then
|
||||||
echo " Sample of invalid domains (showing up to five):"
|
echo " Sample of invalid domains:"
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
echo " - ${line}"
|
echo " - ${line}"
|
||||||
done <<< "${incorrect_lines}"
|
done <<< "${incorrect_lines}"
|
||||||
|
|
Loading…
Reference in a new issue