nos/linkloc

11 lines
336 B
Bash

#!/bin/bash
if [ -z "${1}" ]; then echo "linkInvalid"; exit 1; fi;
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@' \
)
if [ -z "$LOCATION" ]; then echo "${1}"; else echo "$LOCATION"; fi