nos/linkloc

11 lines
336 B
Plaintext
Raw Normal View History

2023-09-04 19:56:20 +00:00
#!/bin/bash
2023-09-05 20:01:17 +00:00
if [ -z "${1}" ]; then echo "linkInvalid"; exit 1; fi;
2023-09-04 19:56:20 +00:00
2023-09-05 20:01:17 +00:00
LOCATION=$(\
curl -L --head --silent -A "getloc" "${1}" | grep -ie '^location' \
| grep -e 'http../' | tail -1 | cut -d'?' -f1 | cut -d' ' -f2 \
| sed 's@^.*reddit.com@https://old.reddit.com@' \
2023-09-04 19:56:20 +00:00
)
2023-09-05 20:01:17 +00:00
if [ -z "$LOCATION" ]; then echo "${1}"; else echo "$LOCATION"; fi