sed - How to extract IP address using sed?

前端 未结 5 2056
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 23:36

This is for an assignment so I have no choice but to use sed.

Given a file messages, how can I extract all the IP addresses and print them?

I first

5条回答
  •  孤城傲影
    2021-01-04 00:19

    You can do that too:

    Windows:

    ipconfig | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1' | sed '2 d' | head -n1;
    

    OSX:

    ifconfig | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1' | sed '1 d' | head -n1;
    

提交回复
热议问题