Comments on: Use wget(1) To Expand Shortened URLs https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/ Linux. GNU. Freedom. Fri, 01 Dec 2017 15:29:07 +0000 hourly 1 https://wordpress.org/?v=5.0-alpha-42199 By: David https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-131015 Thu, 05 Dec 2013 13:39:59 +0000 http://pthree.org/?p=2083#comment-131015 if you just want the URL resolved, you can add "-O /dev/null" to avoid having lots of files with the content of url

]]>
By: Use wget(1) To Expand Shortened URLs https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-117186 Mon, 19 Nov 2012 18:47:42 +0000 http://pthree.org/?p=2083#comment-117186 [...] via pthree.org [...]

]]>
By: Lauri Ranta https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116779 Wed, 04 Jul 2012 09:36:18 +0000 http://pthree.org/?p=2083#comment-116779 `curl -s -o /dev/null --head -w "%{url_effective}\n" -L "https://t.co/6e7LFNBv"`

- `--head` or `-I` only downloads HTTP headers
- `-w` or `--write-out` prints the specified string after the output
- `L` or `--location` follows location headers

]]>
By: Aaron Toponce https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116074 Sun, 23 Oct 2011 02:37:46 +0000 http://pthree.org/?p=2083#comment-116074 @fRIOUX Schmidt- I only use ZSH, and it works fine from here. What is proto.h and Alarm.cpp? I would probably start from there.

]]>
By: fRIOUX Schmidt https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116073 Sat, 22 Oct 2011 23:41:05 +0000 http://pthree.org/?p=2083#comment-116073 For some reason this doesn't seem to work on zsh; when I run the final updated version here is my output:

helena [14105] ~/code/WLS «master¹» $ expandurl http://t.co/LDWqmtDM
proto.h:/* Alarm.cpp */
proto.h:/* Alarm.cpp */

Any ideas?

]]>
By: Weboide https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116071 Fri, 21 Oct 2011 13:26:47 +0000 http://pthree.org/?p=2083#comment-116071 This works the best for me. It does not create any file.
expandurl() { wget --spider -S $1 2>&1 | grep ^Location; }

]]>
By: toobuntu https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116059 Wed, 19 Oct 2011 04:45:19 +0000 http://pthree.org/?p=2083#comment-116059 Well, this will return the expanded URI only:
curl -sIL http://t.co/LDWqmtDM | grep '^Location' | tail -n 1 | awk '{print $2}'

]]>
By: Seth https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116058 Tue, 18 Oct 2011 22:50:12 +0000 http://pthree.org/?p=2083#comment-116058 No discussion about something in wget is complete without the curl version:

curl -sIL http://t.co/LDWqmtDM | grep '^Location'

]]>
By: M https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116057 Tue, 18 Oct 2011 22:46:00 +0000 http://pthree.org/?p=2083#comment-116057 Thanks, for the post and comments.

]]>
By: Dexter https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116056 Tue, 18 Oct 2011 19:30:41 +0000 http://pthree.org/?p=2083#comment-116056 The --spider option causes wget to only make HEAD requests, so you don't have to worry about it downloading the page. The -S just makes it include the headers in the output.

]]>
By: Aaron Toponce https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116055 Tue, 18 Oct 2011 19:11:10 +0000 http://pthree.org/?p=2083#comment-116055 @Dexter- Awesome! I read about --spider in the manual, but it still downloads the page it lands on, which could be quite large (in the case of a PDF, for example). Instead, it appears that the '-S' switch is superior.

]]>
By: Dexter https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116053 Tue, 18 Oct 2011 17:47:20 +0000 http://pthree.org/?p=2083#comment-116053 expandurl() { wget --spider $1 2>&1 | grep '^Location' }

]]>
By: Aaron Toponce https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116052 Tue, 18 Oct 2011 16:34:21 +0000 http://pthree.org/?p=2083#comment-116052 @Me- That is loaded with awesome-sauce. Thanks for sharing! I was thinking about if something like that was possible on the way into work this morning. Glad to see it is.

]]>
By: Me https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116051 Tue, 18 Oct 2011 16:30:33 +0000 http://pthree.org/?p=2083#comment-116051 In the expandurl() function, changing "--max-redirect=$2" to "--max-redirect=${2:-0}" lets you skip specifying the second parameter whenever you want max-redirect set to 0.

]]>
By: Charles Profitt https://pthree.org/2011/10/18/use-wget1-to-expand-shortened-urls/#comment-116050 Tue, 18 Oct 2011 14:53:32 +0000 http://pthree.org/?p=2083#comment-116050 Thanks for posting this... it certainly looks to be a much better way of trying to determine if I want to click on a shortened link. I never knew about the max redirect on wget so this has been a good lesson there as well.

]]>