仅从批处理文件输出日志文件中的某些结果

时间:2012-07-30 14:26:47

标签: windows logging batch-file

批处理文件比较新,所以请帮帮我;)。我要做的是创建一个自定义的日志文件。简单的例子:

ipconfig >> ip.log

这将显示所有与TCP / IP相关的信息。

假设我只需要用户查看IP和默认网关,因此输出ip.log中的结果应如下所示:

IPv4 Address: xxx.xxx.xxx.xxx
Default Gateway: xxx.xxx.xxx.xxx

我该怎么做?

1 个答案:

答案 0 :(得分:3)

通常,您会使用filter来达到此目的。您想要对某些字符串进行过滤,因此findstr命令是自然选择:

ipconfig | findstr /c:"IPv4 Address" /c:"Default Gateway" >>ip.log