批处理变量=%variable:〜1%是什么意思 [英] what does it mean batch set variable=%variable:~1%

查看:85
本文介绍了批处理变量=%variable:〜1%是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以在下面的批处理文件语句中解释:~1%是什么吗?我为服务器名称分配了%variable的值,并尝试了echo %variable.我得到与输出相同的服务器名称.谁能解释下面的声明如何工作?

Can anyone explain what is :~1% in the below statement in a batch file? I assigned the value of %variable to servername and tried echo %variable. I get the same server name as output. Can anyone explain how the statement below works?

set variable=%variable:~1%

推荐答案

这是subs字符串扩展的符号,请看一下您会理解的输出格式命令行.

this is notation for subs string expansion , look at this out put form command line you will understand.

C:\>set temp=stackoverflow.com

C:\>echo %temp%
stackoverflow.com

C:\>echo %temp:~5%
overflow.com

C:\>echo %temp:~5,8%
overflow

C:\>

如果您还不了解,这里是语法(以我的话来说)

if you have not understood , here is syntax (in my words)

set variable=%variable:~startingCharector [,OptionalLenghtOfCharctors]%

其中

OptionalLenghtOfCharctors默认情况下会采用字符串的剩余字符.

OptionalLenghtOfCharctors by default it takes remaining characters of string.

这篇关于批处理变量=%variable:〜1%是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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