简体   繁体   English

使用sed将字符串替换为whois命令输出

[英]Use sed to replace string with whois command output

I have a text file, containing the string ${whois} . 我有一个文本文件,包含字符串${whois}

I wish to replace ${whois} with a whois command output of an IP address or domain. 我希望将${whois}替换${whois} IP地址或域的whois命令输出。 The result of a whois is pretty long and it generally goes wrong with everything I've tried to far. whois的结果相当长,通常我尝试过的所有操作都会出错。

I get errors such as unterminated 's' command or invalid regular expressions , and so on. 我收到诸如unterminated 's' commandinvalid regular expressions错误。

Can anyone provide me a working command that replaces the keyword ${whois} with a whois output of a domain or IP address? 谁能提供给我一个有效的命令,用域或IP地址的whois输出替换关键字${whois}

Try 尝试

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM