How do you extract IP addresses from files using a regex in a linux shell?

前端 未结 19 1689
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 02:43

How to extract a text part by regexp in linux shell? Lets say, I have a file where in every line is an IP address, but on a different position. What is the simplest way to e

19条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 03:24

    You could use grep to pull them out.

    grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file.txt
    

提交回复
热议问题