I'm searching for a way to fetch IP address of the domain requested with
wget fails, it terminates with non-zero exit status, and the errors are written to the standard error descriptor (2).
So you can check the exit code (
$? variable), and parse the strings written to the standard error:
url='http://stackoverflow.com/users/edit/1646322' output=$( wget "$url" 2>&1 ) if [[ $? -ne 0 ]]; then printf '%s' "$output" | \ perl -ne '/^Connecting to .*\|([^\|]+)\|/ and print $1' fi