shift
嚯嚯 发表于 2020-06-28 15:13浏览次数:
shift命令改变可替换参数的在批处理程序的位置。
The shift command changes the position of replaceable parameters in a batch program.
目录:
1 shift 运行系统环境
2 shift 语法
3 shift 示例
shift 运行系统环境
Windows 95
Windows 98
Windows xp
Windows vista
Windows 2000
Windows 7
Windows 8
Windows 10
Windows NT
Windows ME
MS-DOS 3.00及以上
shift 语法
Windows 2000, Windows XP, 及更高版本的语法
更改批处理文件中可替换参数的位置。
SHIFT [/n]
如果启用了命令扩展,则SHIFT命令支持/ n开关,该开关告诉命令在第n个参数处开始移位,其中n可以介于零和八之间。下面的命令会将%3转移到%2,将%4转移到%3,依此类推,而不会影响%0和%1。
SHIFT /2
Windows 95,Windows 98和Windows ME的语法
更改批处理文件中可替换参数的位置。
SHIFT
Windows 2000, Windows XP, and later syntax
Changes the position of replaceable parameters in a batch file.
SHIFT [/n]
If Command Extensions are enabled, the SHIFT command supports the /n switch that tells the command to start shifting at the nth argument, where n may be between zero and eight. The command below would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected.
SHIFT /2
Windows 95, Windows 98, and Windows ME syntax
Changes the position of replaceable parameters in a batch file.
SHIFT
shift 示例
下面的示例将在批处理文件中完成;在此示例中,我们将命名批处理文件test.bat,其中包含以下几行。
@ECHO OFF
ECHO - %1
SHIFT
ECHO - %1
创建上面显示的示例test.bat文件后,如果要在MS-DOS提示符下键入以下命令,它将打印“-ONE”,然后“-TWO”。该命令通常用于遍历每个命令扩展名或删除命令扩展名。
TEST ONE TWO
The example below would be done in a batch file; in this example, we are naming the batch file test.bat and it contains the following lines.
@ECHO OFF
ECHO - %1
SHIFT
ECHO - %1
After creating the example test.bat file shown above, if you were to type the command below at the MS-DOS prompt, it would print "- ONE" and then "- TWO". This command is often used to work through each of the command extensions or remove command extensions.
TEST ONE TWO