Dennis van der Veeke Dennis van der Veeke - 8 months ago 70
Linux Question

Use sed to replace string with whois command output

I have a text file, containing the string ${whois}

I wish to replace ${whois} with a whois command output of an IP address or domain. The result of a whois is pretty long and it generally goes wrong with everything I've tried to far.

I get errors such as "unterminated 's' command" or invalid regular expressions, and so on.

Can anyone provide me a working command, that replaces the keyword ${whois} with a whois output of a domain or IP address?


Answer Source


$ whois > whois_out.txt
$ sed -e '/${whois}/r whois_out.txt' -e '//d' input_file.txt