Skip to content

Instantly share code, notes, and snippets.

@Da-Juan
Created November 4, 2016 14:12
Show Gist options
  • Save Da-Juan/e7bbecc87f45a4e487c6709e5d06f182 to your computer and use it in GitHub Desktop.
Save Da-Juan/e7bbecc87f45a4e487c6709e5d06f182 to your computer and use it in GitHub Desktop.
Get IPs from a file containing URLs
#!/bin/bash
for i in $(sed -r 's@^http[s]?://([[:alnum:].]+)[/]?$@\1@' $1); do
echo "=== $i ==="
echo $i | egrep -q "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
if [ $? -eq 0 ]; then
echo $i
else
host -t A $i | grep address | awk '{print $4}'| sort
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment