Last active
January 3, 2017 10:54
-
-
Save daformat/d146a148d6296501cc13 to your computer and use it in GitHub Desktop.
Extract any url found in input URL (the shell-noob way)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
echo "Url to extract values from:"; | |
read TMPCURLURL; | |
RESULT=`curl -L $TMPCURLURL`; | |
# Extract urls within double quotes | |
echo $RESULT | grep -oE "\"http://.*\"" | cut -d " " -f1 | cut -d '"' -f2; | |
# Extract urls within single quotes | |
echo $RESULT | grep -oE "'http://.*'" | cut -d " " -f1 | cut -d "'" -f2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reminder: if you paste this directly in your terminal, check that the interactive_comments is enabled (
set -k
)Alternatively, here's the one-liner version of the above script without any commments: