Smokes your problems, coughs fresh air.

Tag: wget

Wget one-liner

Earlier today, I wanted to download all songs by this totally kick-ass rap outfit:

wget -q -O - \
| sed --quiet -e 's#^.*<a href="\(nummers/.*\.mp3\).*$#\1#p' \
| sort -u \
| wget -i - -B ''

The same command-line, now using GNU long options to increase readability:

wget --quiet --output-document=- \
| sed --quiet --expression='s#^.*<a href="\(nummers/.*\.mp3\).*$#\1#p' \
| sort --unique \
| wget --input-file=- --base=''

Using wget to download all files on a page

Just a quick one-liner I used to download a bunch of MIDI files from an on-line listing of Chopin MIDIs:

$ wget -q -O - \
| grep 'href=".*\.mid"' \
| sed -e 's/^.*href="\(.*\)".*$/\1/' \
| xargs -i{} wget{}

Maybe not so useful to you, but it’s a good demonstration of applying the hacker’s mentality to one of those moments where, after clicking the fourth link or so, I find myself thinking: Wouldn’t spending a few moments on a one-liner be much more fun than clicking through and saving 44 more links?

Useful or not, I am now testing timidity’s piano sound with a nice rendition of Chopin in the background whereas, without this trick, I’d still be right-click-click-saving links instead of writing this post. It’s up to you to decide whether this is actually good or bad. 😛

© 2024 BigSmoke

Theme by Anders NorenUp ↑