【发布时间】:2017-07-07 18:17:55
【问题描述】:
我在 Windows 中有一个 environment variable,它有一个 value,如下所示
"https://xx.xx.xx.xx:yyyy/xxxx (login: xxx, password: xxxxx)"
我的任务是从环境变量中extract the IP address and port number。我能够在 Linux 环境中做到这一点。命令如下
echo "$env_variable" | cut -d '/' -f 3 | cut -d ':' -f 1 - for the IP Address
echo "$env_variable" | cut -d '/' -f 3 | cut -d ':' -f 2 - for the port number
有人可以帮我在 Windows 系统上使用 windows batch command 做同样的事情吗?
编辑
这里xx.xx.xx.xx是IP地址,yyyy是端口号。
【问题讨论】:
-
我宁愿把数据放在更好的格式,例如多个变量,它们毕竟是为了方便机器使用,而不是为用户提供漂亮的打印信息
标签: linux windows parsing batch-file