简体   繁体   中英

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?

Try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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