How to match IP address by using 'findstr'? Or any other method of batch in windows

前端 未结 5 1465
广开言路
广开言路 2021-01-21 07:30

    As the title said, I want to match ip address with batch in windows, please tell me how I can do it?
    I see that \"finds

5条回答
  •  梦谈多话
    2021-01-21 08:30

    In case the input of your findstr command should not be the result of ipconfig, you could use the following line of code to look for an ip-address in a text or csv file.

    findstr /r "\<[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\>" filename.txt
    

    It adds to metacharacters to the answer of user Joey. "\<" at the beginning and ">" at the end. Even though such a string might not be very common (or very unlikely to occur) this makes sure that no string in an ip-address-like format but with an alphabetic character at the end and/or the beginning (e.g. A198.252.206.16 or 198.252.206.16A) is returned.

提交回复
热议问题