如何在Windows命令提示符下分割命令输出? [英] How to split command output in Windows command prompt?

查看:1239
本文介绍了如何在Windows命令提示符下分割命令输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中是否有 split 命令,用于分割命令输出?我的命令是:

Is there a split command in Windows, to split command output? My command is:

ipconfig | findstr /i "Default gateway" | findstr [0-9]

,输出为:

Default Gateway...: x.x.x.x

我需要一个命令,输出应该只有 xxxx

I need a single command, and the output should be only x.x.x.x.

推荐答案

p>没有完全一个拆分函数,但你可以使用 FOR 来完成你想要的:

there is not exactly a split function, but you can use FOR to accomplish what you want :

for /f "tokens=2 delims=:" %%i  in ('ipconfig ^| findstr /i "Default gateway" ^| findstr [0-9]') do echo %%i

这篇关于如何在Windows命令提示符下分割命令输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆