I am writing a bash script to extract a domain out of string of the form:
....domain name example.com...
and I want to output example.com.
How can I use matching to output this domain name?
I am writing a bash script to extract a domain out of string of the form:
....domain name example.com...
and I want to output example.com.
How can I use matching to output this domain name?
If the the format is exactly as you say, then this will suffice:
awk '/domain name/{print $3}'
If the string is stored in a variable, you can use it as follows:
awk '/domain name/{print $3}' <<< $string_name
If the string is stored in a file with other strings, one per line:
awk '/domain name/{print $3}' < input_file > output_file