replace all 'grep -P' instances (#59)

This commit is contained in:
Mason Rowe 2023-03-24 23:23:48 -04:00
parent f275b27f34
commit dd110ee036

16
yabs.sh
View File

@ -278,25 +278,25 @@ function ip_info() {
return
fi
local country=$(echo "$response" | grep -Po '"country": *\K"[^"]*"')
local country=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^country/ {print $2}' | head -1)
country=${country//\"}
local region=$(echo "$response" | grep -Po '"regionName": *\K"[^"]*"')
local region=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^regionName/ {print $2}')
region=${region//\"}
local region_code=$(echo "$response" | grep -Po '"region": *\K"[^"]*"')
local region_code=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^region/ {print $2}' | head -1)
region_code=${region_code//\"}
local city=$(echo "$response" | grep -Po '"city": *\K"[^"]*"')
local city=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^city/ {print $2}')
city=${city//\"}
local isp=$(echo "$response" | grep -Po '"isp": *\K"[^"]*"')
local isp=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^isp/ {print $2}')
isp=${isp//\"}
local org=$(echo "$response" | grep -Po '"org": *\K"[^"]*"')
local org=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^org/ {print $2}')
org=${org//\"}
local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"')
local as=$(echo "$response" | sed -e 's/[{}]/''/g' | awk -v RS=',"' -F: '/^as/ {print $2}')
as=${as//\"}
echo
@ -730,7 +730,7 @@ function iperf_test {
done
# Run a latency test via ping -c1 command -> will return "xx.x ms"
[[ ! -z $LOCAL_PING ]] && LATENCY_RUN="$(ping -c1 $URL 2>/dev/null | grep -Po 'time=.*' | sed s/'time='//)"
[[ ! -z $LOCAL_PING ]] && LATENCY_RUN="$(ping -c1 $URL 2>/dev/null | grep -o 'time=.*' | sed s/'time='//)"
[[ -z $LATENCY_RUN ]] && LATENCY_RUN="--"
# parse the resulting send and receive speed results