awk syntax help

I don't get correct output when I run this command line:

nmap -sP failedhost.com | grep -i failed | awk -F '{print $6}'

I basically want it to return 'failedhost.com' but its just showing the output of the nmap scan.

what does a sample output of 'nmap -sP failedhost.com' look like AND what part of it are you after?

nmap -sP asasdfasfasdfsaf.com | grep -i failed
Failed to resolve given hostname/IP: asasdfasfasdfsaf.com. Note that you can't use '/mask' AND '1-4,7,100-' style IP ranges
WARNING: No targets were specified, so 0 hosts scanned.

I want to get $6 or ' asasdfasfasdfsaf.com.'

nmap -sP failedhost.com | nawk '/^[Ff]ailed/ { print $6}'

This still doesn't work for me unfortunately :confused:

Difficult to help the "doesn't work for" description.
Could you elaborate what you've done, what you're seeing and what would be the desired output.
Please use code tags when quoting data samples.

PMJI ..., but when nmap fails, it sends its output to std error, not std out, so it needs to be redirected:

nmap -sP failedhost.com  2>&1  | nawk '/^[Ff]ailed/ { print $6 }'

The message from Nmap is printed to stderr because the hostname failed to resolve (you are not seeing the entire nmap output) and neither grep or awk are seeing stderr - grep is suppressing everything from stdout so you end-up just looking at stderr. Not sure how you would work around that.
Yeah, like rubin said.

Thanks guys!