more performant grepping

This commit is contained in:
Roberto Polverelli Monti 2021-01-19 10:29:46 +01:00
parent b777c7470e
commit 995c29e378

View File

@ -3,8 +3,7 @@
if echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null; then
url="$1"
else
url="$(grep 'rel="self"' "$1" |
grep xml |
url="$(grep -Eom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$1" |
sed -E 's_^.*href="(https?://[^"]+)".*$_\1_')"
! grep "https*://\S\+\.[A-Za-z]\+\S*" <<<"$url" &&