0

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?

Matthew Schuchard
  • 25,172
  • 3
  • 47
  • 67

1 Answers1

0

Try

$ whois > whois_out.txt
$ sed -e '/${whois}/r whois_out.txt' -e '//d' input_file.txt
Community
  • 1
  • 1
Sundeep
  • 23,246
  • 2
  • 28
  • 103
  • Works! I forgot to mention one thing; The output goes into a .html file, meaning the enters get screwed up. Is there a way to insert
    tags instead of enters?
    – Dennis van der Veeke Nov 20 '16 at 11:33
  • you can process the `whois_out.txt` file whatever way you like using sed/awk/perl/other-text processing commands.. and then pass it on to this `sed` command... try it out.. see https://stackoverflow.com/documentation/sed/topics for examples if you face difficulties.. and then if you are stuck, you can ask another question... – Sundeep Nov 20 '16 at 11:36