Recovering front-end developer, now I just write JavaScript

Unshorten URLs

How to convert a list of short URLs into a list of unshortened URLs

Say you have a text file called old-urls.txt that looks like this:

https://example.com/?p=1234
https://example.com/?p=5678

We know those redirect to a fuller URL, but don't yet know what.

Run this in your terminal:

cat old-urls.txt | while read f; do echo "${f}"; curl -Ls -o /dev/null -w %{url_effective} "${f}" -O; echo "\n"; done;

And get a readout in the terminal like:

https://example.com/?p=1234
https://example.com/2022/02/03/my-post

https://example.com/?p=5678
https://example.com/2022/02/04/another-post

You can then turn that into some JSON or whatever format you need to work with.