Dennis van der Veeke Dennis van der Veeke - 19 days ago 7
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?

Thanks!

Answer

Try

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