In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "what are the batch commands that come with DOS". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the batch commands that come with DOS.
The file name is a combination of the file path and the file name, such as C:\ DOS\ COMMAND.COM.
DIR displays files and folders (directories).
Usage: DIR [file name] [option]
It has many options, such as / A for displaying all files (that is, files with implicit and system attributes), / S for also displaying files in subfolders, / P for split-screen display, / B for displaying only file names, and so on.
Such as DIR A*.EXE / A / P
This command displays all files (folders) with the suffix EXE starting with An in the current folder.
CD or CHDIR changes the current folder.
Usage: CD [folder name]
Displays the current path if there is no folder name.
Create a folder for MD or MKDIR.
Usage: MD folder name
RD or RMDIR deletes the folder.
Usage: RD folder name
Note: this folder must be empty.
DEL or ERASE deletes the file.
Usage: DEL/ERASE file name
COPY copies files.
Usage: COPY file name 1 [file name 2] [option]
Such as COPY / B Atom B C
This command combines two binaries An and B into one file C.
TYPE displays the contents of the file.
Usage: TYPE file name
REN or RENAME changes the file name and folder (directory) name.
Usage: REN file (folder) name 1 file (folder) name 2
EDIT edits files, and binaries and multiple files can also be edited in MS-DOS 7.x.
Usage: EDIT [file name] [option]
Such as EDIT / 70 C:\ COMMAND.COM
This command edits the C:\ COMMAND.COM file in binary mode.
FORMAT formats the disk.
Usage: FORMAT drives [options]
It has many options, such as / Q is quick formatting, / U means unconditional formatting (that is, it cannot be recovered using commands such as UNFORMAT), / V specifies the volume label name of the disk, and so on. It also has many undisclosed parameters.
MEM displays the memory status.
Usage: MEM [option]
It also has many options, such as / C can list the memory occupation of all programs, / D displays details such as the program that resides in memory and the status of the device driver, / F displays the total amount of free memory, / M displays the module information in memory, and / P displays split-screen display. There is also a hidden / An option to display HMA information.
MOVE moves a file or folder, and you can also change the name of the file or folder.
Usage: MOVE file [folder] 1 file [folder] 2
For example, MOVE C:\ * .EXE D:
This command moves all files with the extension EXE under the root folder of disk C to disk D.
XCOPY copies files or folders.
Usage: XCOPY file [folder] name 1 [file [folder] name 2] [option]
It has many options, such as / S can copy files in the entire folder (including subfolders), / E specifies to include empty folders, / V means to verify the correctness of copied files after copying, / Y means to confirm, and so on.
CLS clears the screen.
Usage: CLS
SYS transmission system, which transfers system files (such as IO.SYS, etc.) from one place to a specified drive.
Usage: SYS folder name [drive]
Such as SYS C:\ DOS A:
This command transfers the system files located in the C:\ DOS folder to disk A.
DATE displays or sets the date.
Usage: DATE [date]
TIME displays or sets the time.
Usage: TIME [time]
DOS also comes with some other commands, such as SORT (sort), FIND (find characters) and so on.
@: put this symbol before other commands in the batch file, and the command itself will not be displayed at run time.
For example, the @ ECHO OFF command is often used at the beginning of the batch file.
CALL: invokes another batch file from one batch file, and continues to execute the original batch file after the call.
Usage: CALL [approval document name]
Note: you can also use the COMMAND / C command to do the same.
CHOICE: select the command. This is an external DOS command, but it is mainly used in batch files.
The optional items will be prompted after the CHOICE command is executed, and the option will be selected by pressing a key.
Usage: CHOICE: [/ C [:] keystroke table] [/ N] [/ S] [/ T [:] Select value, seconds] [display text]
Among them, / C represents the optional key, / N indicates that the prompt message is not displayed, / S indicates the case-sensitive mode, and / T indicates that a selection value defined in / C is automatically executed if there is no selection within the approved time. The display text is a prompt when the CHOICE command is executed. The selection result will be represented by the ERRORLEVELL value.
ECHO: displays the specified information. It is usually displayed on the screen.
For example, ECHO Hello will display the words Hello on the screen.
In addition, ECHO ON | OFF is used to set whether the command itself is displayed when the batch file is executed. ECHO OFF means the same as @, but it is a separate command and cannot be placed before other commands like @.
FOR: runs the appropriate command for the specified file.
As you know, many commands under DOS support wildcard characters, such as? And *, you can specify one batch of files at a time, which is very convenient. However, not all DOS commands support wildcards, such as TYPE (file content display command). It doesn't matter with the FOR command, which allows the TYPE command to display more than one file at a time.
Usage: FOR% variable name IN (fileset) DO command [command parameters]
Note: the above is the fixed form of the FOR command, the position of IN and DO must be correct, otherwise syntax errors will be prompted.
For example, the FOR% F IN (*. *) DO TYPE% F command can realize the TYPE command to display multiple files at a time.
Note:% F is a variable name, which can also be replaced by% G, etc., but it must be consistent. Replace with% F in the batch file.
GOTO: go to a label inside the batch file to execute.
As we all know, in programming, you often need to repeat or jump somewhere to continue execution, such as the GOTO command in the BASIC language. The GOTO command in the batch file can perform a similar function.
Usage: GOTO [label name]
Among them, the label name can be set at will, such as Hello, etc. Set the label with a ":" symbol, such as ": Hello", and use the GOTO Hello command to go to the location where ": Hello" is located to continue executing the batch file.
IF: conditional judgment command. This is a very useful batch command.
Use 1:IF [NOT] EXIST file name command [command parameters]
Meaning: if a file does not exist, a command will be executed.
Use 2:IF [NOT] ERRORLEVEL error to return code command [command parameters]
Meaning: if the error return code [not] is greater than or equal to the specified code, a command will be executed.
Where ERRORLEVEL represents an error return code, which is very useful. For many DOS commands, due to different results of execution (such as successful execution, failed execution, or interrupted by the user, etc.), these commands return different codes to represent different results. The IF ERRORLEVEL command executes different commands according to the different codes produced by this different result, usually after a command. Such as IF ERRORLEVEL 1 ECHO OK! Indicates that "OK!" will be displayed on the screen if the current error return code is greater than or equal to 1. The words.
Use 3:IF [NOT] string 1 "= string 2 command [command parameters]
Meaning: execute a command when string 1 and string 2 are [not] equal.
PAUSE: pauses the execution of the batch file and displays the words "press any key to continue".
REM: add comments. Used to increase the readability of files and will not be executed. You can also use:: instead.
SHIFT: change the location of replaceable parameters in the batch file.
A replaceable parameter is a special parameter that can only be used in batch files. These parameters are entered by the user when executing the batch command. For example, we execute the DIR / S / W command, where DIR is the command name and / S and / W are its execution parameters. In the batch file, these command parameters will be assigned to the replaceable parameters, such as / S will be% 1 replaceable parameter% 2, and so on, while the command itself will be given% 0. Batch files operate on parameters entered during execution using replaceable parameters. For example, there is a batch file called MYFILE.BAT, which executes MYFILE.BAT YES under the command line, so the value of% 0 is the value of MYFILE.BAT,%1 is "YES". In this batch file, you can use commands such as IF to determine the value of parameters such as% 1, and then perform different operations according to these values, such as IF "% 1" = "YES" GOTO YES.
The SHIFT command takes no arguments, and the result of execution is to change the value of% 0 to the value of% 1, and the value of% 1 to the value of% 2, and so on. Pay attention to its irreversibility. Because batch files may be executed with more than 10 running parameters, and replaceable parameters can only be from% 0 to% 9, you can only use the SHIFT command if you want to get parameter values after% 9. At this point, the entire parameter column will be pushed forward.
At this point, I believe you have a deeper understanding of "what are the batch commands that come with DOS?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.