diff --git a/README.md b/README.md index 4a08170..90f347a 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,32 @@ Notes: perl -pi.bak -e 's/old-string/new-string/g' my-files-*.txt ``` +- To strip URLs from surrounding HTML: +```sh + $ cat example.html + Some text Lion roar So cool!
+ More stuff Bird callPretty
+ No link on this line. + Some text CricketsRelaxing.
+ Some text Ocean waves.Meditate!
+ More junk. + + $ perl -ne 'print if s/^.*href="([^"]+)".*$/$1/' example.html + http://example.com/roar.mp3 + http://example.com/bird.mp3 + http://example.com/crickets.mp3 + http://example.com/beach.mp3 + + # Make a script to download all the files. + $ perl -ne 'print if s/^.*href="([^"]+)".*$/wget $1/' example.html > download.sh + + $ cat download.sh + wget http://example.com/roar.mp3 + wget http://example.com/bird.mp3 + wget http://example.com/crickets.mp3 + wget http://example.com/beach.mp3 +``` + - To rename many files at once according to a pattern, use `rename`. For complex renames, [`repren`](https://github.com/jlevy/repren) may help. ```sh # Recover backup files foo.bak -> foo: