Home >Operation and Maintenance >Linux Operation and Maintenance >What is the difference between for command in dos and linux?

What is the difference between for command in dos and linux?

WBOY
WBOYOriginal
2022-05-23 17:02:161906browse

Difference: In dos, this command is used to execute commands on files in the file group through a loop. The syntax is "FOR parameter% variable name IN (file or command) DO command"; in linux, this command Command is used to use a command set through a loop, and the syntax is "for variable name in value list do command done".

What is the difference between for command in dos and linux?

The operating environment of this tutorial: linux7.3&&DOS8.0 system, Dell G3 computer.

What is the difference between the for command in dos and linux

linux

In linux, the for command is used to create a loop , which loops through a series of values ​​to use a command set in the series, the syntax is "for variable name in value list do command sequence done".

The for command is provided in the shell, which is used to create a loop that repeats through a series of values. Each time it is repeated, a value in the series is used to execute a defined set of commands.

The basic format of the for statement is as follows:

for 变量名 in 值列表
do
命令序列
done

Provide a series of values ​​for iteration (the result of the previous output, this sentence is used for input) in the parameter list. There are several different ways to specify values ​​in a list.

dos in

for help document

Execute a specific command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

Format: FOR [Parameter] %% variable name IN (related file or command) DO executed command

Function: For one or a group of files, strings or command results Each object executes a specific command to achieve the desired result.

Note: When using the FOR command in a batch file, please use %%variable instead of %variable to specify variables. Variable names are case-sensitive, so %i is different from %I.

About: the for command can take parameters or not. When taking parameters, it supports the following parameters:/d /l /r /f

  • %variable specifies a single-letter replaceable parameter.

  • (set) Specifies a file or a group of files. Wildcard characters can be used.

  • command Specifies the command to execute for each file.

  • command-parametersSpecify parameters or command line switches for a specific command.

When using the FOR command in a batch program, please use %%variable

instead of %variable to specify variables. Variable names are case-sensitive, so %i is different from %I.

Recommended learning: Linux video tutorial

The above is the detailed content of What is the difference between for command in dos and linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn