批处理中的符号用途说明


  • [ & ] (Ampersand) (AMM-perr-sand) Used by 4DOS to indicate that both standard out and standard error are to be directed to a file or device. It also is used to denote command-line parameters in batch files.



  • [ && ] (Double Ampersand) Used by 4DOS as a special type of command separator. It is used between two commands where one wants the command following `&&' to be executed only if the first command is successful. This will work only with a command used before `&&' that returns an exit code of `0' (zero). If exit codes are employed, `zero' is the one generated by most DOS commands when operations are completed with no (zero) errors. That is, the operation was successful. For more on this aspect of DOS commands, see DOS Exit Codes. Also see the "Double Pipe" symbol farther on.


  • [ @ ] (Asperand or At) This sign is used in batch files to prevent the text following it on the same line from being displayed on the screen. An example is "ECHO OFF". It is used at the start of most batch files to turn off screen echoing (displaying) for all lines following. Employing `@' with it as "@ECHO OFF", will prevent this Asperand and the words "Echo Off" from appearing on screen.

        As well as the above, `@' is used by 4DOS to designate variable functions. "@FILEDATE" will return a file's date, as an example.

        Finally, the `@ sign is employed to designate file lists in many versions of DOS. "DEL @FILENAME.lst" means that DOS will delete the files listed in "FILENAME.lst".


  • [ * ] (Asterisk) (ASS-ter-isk) (Erroneously referred to as "Star".) DOS uses this as a wild card to represent one or more characters. So "*.txt" would mean all files with an extension of "txt". "READ-ME.*" means all `Read-Me' files with any extension. They typically would be "READ-ME.txt" or "READ-ME.doc".

        "A*.txt" means all files with an extension of "txt" that begin with the letter `A'. Some versions of DOS allow an Asterisk at the start, as well: "*-ME.doc" means all files with an extension of "doc" that have "-ME" at the end of the file name.

        Some DOS versions use this sign coupled with a percent sign (%*) to represent all parameters on the command line in a batch file.

        In DOS SHELL, the Asterisk key is used to expand an entire directory level. Coupled with the Control key, it will expand the entire tree to display all subdirectories under all directories. (Other shells work this way, as well.)


  • [ \ ] (Backslash) The Backslash is used in the path as a separator between the drive and first directory and between directories themselves. "C:\BATCH\TEST" designates that the TEST directory is a subdirectory of BATCH, and that both reside on the `C' drive.

        The Backslash by itself represents the root directory. So "CD \" means to change to the root directory of the current drive.

        The Backslash is used in older versions of DOS when one cancels a command line. It appears at the end of the cancelled line with the cursor dropping down to the next line ready for another command.

        Another usage is by issuing "ECHO\", a blank line will be placed on to the screen in some DOS versions.


  • [ ^ ] (Caret) (KAIR-ett), also referred to as the "Circumflex" (SIR-kum-flecks). It is a representation of the keyboard "Control" key. So ` ^C ' means "Control C".

        4DOS also uses the Caret as a command separator when one is issuing multiple commands on the same line.


  • [ : ] (Colon) (KOH-lon) This is used as a drive-letter designator. So ` E: ' means the `E' drive.

        The Colon is also a label precursor in a batch file:

    (batch commands)
    GOTO END
    (more batch commands)

    :END

        This batch file snippet says to go to a label called "END", skipping any remaining batch commands. DOS finds it by looking for a single Colon and the matching text following.

        Another usage is by issuing "ECHO:", a blank line will be placed on to the screen in many DOS versions.

        Finally, the Colon is a delimiter in the time separating the hour, minute and seconds: 10:15:00 AM.


  • [ :: ] (Double Colon) Employed in batch files to allow comments to be inserted. Comments are used to instruct those reading the code about various parts of the file. Text from a second colon onward is ignored by DOS and is not executed or displayed. This is because a colon is an illegal character within a label name.


  • [ , ] (Comma) (KOM-ah) This can be used by the FOR command to separate items in the set contained within the parentheses.

        The Comma is used to separate files names for those commands which can accept multiple file specifications.

        Some versions of the MOVE command allow multiple files to be moved by separating them with commas:

    MOVE FILE-1,FILE-2 C:\ARCHIVES

        In some DOS versions, "ECHO," will produce a blank line on the screen.


  • [ - ] (Dash) (Also called "Hyphen".) Erroneously referred to as "minus" (see farther on), this symbol is used as a switch designator in some DOS programs. In the following PKZIP example, PKZIP is requested to make a compressed archive called "BACKUP.zip" from all the files in the current directory that have the "Archive" attribute set. (The `i' stands for "Incremental".)

    PKZIP -i BACKUP *.*

        The `-i' is a switch used to modify the operation of PKZIP. In this case, it requests that PKZIP be more selective as to which files it places into the compressed archive. Only those with the "Archive" attribute set will be selected with this example. (See DOS Switches for details on using command modifiers.)

        Another Dash usage is as a date delimiter. That is, it separates the digits represeting the month, day and year: 01-01-2011.

        The Dash can be used as a word separator in file names on systems that don't allow spaces: MY-FILE.TXT. (The Underscore may also be used for this purpose.)


  • [ $ ] (Dollar) This is used with the "PROMPT" command to place text on the screen as part of the DOS prompt. It can also control the location of that text and its colours when used to produce the "Escape" character via `$e'. (See "Escape", farther on.) As examples, "PROMPT=$p$g" will show the current path followed by a "Greater Than" sign ( > ), and "PROMPT=$p$t" will show the current path followed by the current time. See your DOS manual or on-screen "Help" for more.

        The Dollar Sign is used by DOSKEY and Toddy as a command-line parameter designator. `$3' represents the third parameter.

        DOS itself uses the dollar sign within the extension for temporary work files.




  • [ . ] (Dot) Erroneously referred to as a "period", this character is used as a separator between a file's name and its extension: "FILE.ext". (See "Point", farther on.)

        As a short name, the Dot can represent the current directory. It appears in directory listings but can be used at the command line any time one needs to refer to the current directory. "DIR ." is the same as "DIR *.*" or "DIR .\". "DEL ." means to delete all of the current directory's files.

        Another Dot usage is as a date delimiter. The dash is the default, but the Dot can be used to separate the month, day and year: 01.01.2011.

        Finally, by issuing "ECHO.", the Dot can be made to output a blank line to the screen in most DOS versions.


  • [ .. ] (Dot Dot or Double Dot) Represents the parent directory. It appears in directory listings but can be used at the command line any time one needs to refer to the parent directory. "DIR .." is the same as "DIR ..\" or "DIR ..\*.*". "DEL ..\" means to delete all of the parent directory's files. One may also refer to the grandparent directory as "..\.." .


  • [ ... ] (Dot Dot Dot or Triple Dot) Represents the grandparent directory in some DOS systems and utilities in addition to "..\..". (See "Ellipsis", next.)


  • [ ... ] (Ellipsis) (el-LIP-sis This is used in DOS SHELL menus to represent that the selection will require more input from the user. Selecting such an item means that a prompt will appear requesting information from the user before the operation will be carried out. (See "Dot Dot Dot" above.)


  • [ = ] (Equals) (EE-kwals) Used to place items into the DOS environment via the "SET" command. "SET PATH=C:\;C:\BATCH;C:\DOS" tells DOS it can look in the ROOT, BATCH and DOS directories for executable files. "SET FILE=BACKUP" makes an environmental variable called "FILE" that will substitute "BACKUP" anywhere "%FILE%" appears. (See DOS Variables for more information.)

        The FOR command can use the Equals Sign to separate items in the set contained within the parentheses:

    FOR %N IN (1=2=3) DO ECHO %N.

        With some DOS versions, "ECHO=" will produce a blank line on the screen.


  • [ == ] (Double Equals) The "IF" command uses this to test if two strings are equal:

    IF "%1" == "" GOTO HELP

    means that if the first parameter on the command line after the batch file name is equal to nothing, that is, if a first parameter is not given, the batch file is to go to the HELP label.


        This may be reversed by placing "NOT" after the command:

    IF NOT "%1" == "" GOTO ACTIONS

    So if the first parameter is not equal to nothing, that is, if it is equal to something, the batch file is to go to the ACTIONS label.


  • [ $e or <- ] (Escape) (eh-SCAPE) This combines with the Left Square Bracket ( [ ) (see farther on) to create "Escape" sequences ($e[ or <-[). It prefaces codes that can clear the screen, place certain text such as Time and Date, on to the screen, position the cursor, change screen and text colours, and redefine keys, among other purposes. An example is:

    <-[1;37;44m. This changes the screen colours to bright white on blue.

    <-[0m resets to the default white on black.

        See "$" (Dollar), farther back.


  • [ / ] (Forward Slash) This symbol is used as a switch designator in most DOS versions and programs. "DIR /W" tells DOS to display a directory in a wide format. (See DOS Switches for details on using command modifiers.

        The Forward Slash is used in some versions of DOS in the FOR command. It represents an escape character and can be used to parse character strings.

        Another Forward Slash usage is as a date delimiter. The dash is the typical default, but Forward Slashes can be used to separate the month, day and year: 01/01/2011.

        In some DOS versions, issuing "ECHO/" produces a blank line on screen.


  • [ // ] (Double Forward Slash) 4DOS uses this to state directives at the command line. It can overide a start-up directive such as one within an INI file. Thus a new option value can be given without having to modify an existing initialisation file.


  • [ > ] (Greater Than) (Also used as a right angle bracket.) The Greater Than symbol allows one to direct output to a file or device. "DIR > DIR.txt" directs the file list produced by DIR to a file instead of the screen. One may also send text to a file directly from the command line via "ECHO (whatever) > WHATEVER.txt". In either case, a new file is automatically created, overwriting any existing one without confirmation. "TYPE DIR.txt > PRN" directs the file contents to the printer port instead of the screen.

        As a Right Angle Bracket, it is used in conjunction with a left angle bracket to designate a Directory in a DIR listing:
     BACKUP       <DIR>         11-17-08  9:09p
     


  • [ >> ] (Double Greater Than) This works partially the same as the single Greater Than symbol by allowing one to direct output to a file, but not to a device. However, in this case when output is directed to a file via Double Greater Than symbols, any existing file contents are not overwritten. As with the previous examples, "DIR >> DIR.txt" and "ECHO (whatever) >> WHATEVER.txt" direct text to a file instead of the screen. If these same commands were to be immediately issued again, the resulting files would be appended to and not overwritten because of the double symbols. So for the latter example of the reissued commands, each resulting file would contain two copies of the same information, one after the other. Repeating them for a third time would add on yet another copy of the information after the first two. In actual operation, the idea of this double symbol is to keep adding different information to the existing file, such as with a log.


  • [ [ ] (Left Square Bracket) A character used in PROMPT and ANSI.sys escape sequences. See the "Escape" character, farther back.)


  • [ < ] (Less Than) (Also used as a left angle bracket.) The opposite to the `>' symbol, "Less Than" takes input.

    MORE < WHATEVER.txt will display the contents of WHATEVER.txt and pause after each screen fills. MORE is taking its input from the file WHATEVER.txt.

    XSET /LOAD < ENVIRO.DEF will direct XSET, an update to the "SET" command, to load a default environment file. XSET takes its input from the file "ENVIRO.DEF" via the "Less Than" redirector. That input is the list of environment variables to load.

        As a Left Angle Bracket, it is used in conjunction with a right angle bracket to designate a Directory in a DIR listing:

     BACKUP       <DIR>         11-17-08  9:09p
     



  • [ - ] (Minus) (MY-nus) Erroneously referred to as "dash" or "hyphen" (see farther back), this symbol is used to reverse the action of a switch by preceding or succeeding its character with a Minus Sign. As an example, "DIR /O:N" tells DOS to display a list of files in a directory and to show them in alphabetical order from `A' through `Z'. "DIR /O:-N" will display the same thing, but show it as `Z' through `A'.

        In the PKZIP example shown earlier, one may tell PKZIP to NOT turn off the archive attribute after placing files into a compressed archive:

    "PKZIP -i- BACKUP *.*.

        Note that the `-i' switch action has been reversed by placing a Minus Sign after it as "-i-". It would be read as "dash `i' minus".

        The Minus key is used in DOS SHELL (and in many other shells) to collapse a selected directory tree.


  • [ # ] (Octothorpe) (AWK-toh-thorp) Also referred to as the "Number Sign", DOS uses this symbol when it "deletes" a file. "Deletes" is in quotation marks because DOS does not really delete (remove) files from a disc when DEL is used. Instead, it changes the first character to an octothorpe, removes the file's reference from the File Allocation Table (FAT), and releases the disc space for other files to occupy as necessary. If the "deleted" file is still complete (not partially or wholly overwritten), undelete utilities simply rename the first character, mark the disc space as used and restore the listing to the File Allocation Table. (Note that if one eventually deletes two files in the same directory that have the same name, or two that are the same except for the first character, DOS will use another symbol to denote deletion since the Octothorpe is now in use.)

        (This symbol goes by different names when used for non-DOS purposes. As an example, the Twitter designation is "hash tag".)

       


  • [ ¶ ] (Paragraph) (Some of you may not see this character on your browser.) It looks like a stylised `double T'. In DOS and some other systems, you should be able to see the actual symbol by issuing `^T' at the command line, or via the key combination of Alt-20. Be sure to use the number pad to enter the `20'.)

        `¶' is used by some DOS versions to allow multiple commands to be issued on the same line at the DOS prompt.

    SET OS=DOS ¶ ECHO %OS%

    ...would set the environmental variable "OS" to equal "DOS" and then display that variable's content. (For more on variables, see DOS Variables.)


  • [ ( ) ] (Parentheses) These are used within the FOR command to define the boundaries of the set. That is, items contained with an opening Parenthesis and closing Parenthesis are called the "set" and they are upon what the FOR commands acts.

        A single Parenthesis is sometimes used by some DOS users in conjunction with the ` == ' (double equals), but it had fallen into disuse, having been supplanted by the ` " ' (double quote). Its purpose, as is with the quotes, is to prevent an error should a parameter not be given or be nothing. It means that there will always be characters able to be compared on each side of the double equals:

    IF )%1 == ) ECHO No Parameter Given.

        Finally, Parentheses can be seen in the DIR output on the line giving the number of files in the listing:

    40 File(s) 3,465,453 bytes


  • [ % ] (Percent) is used to denote a variable. It is followed by a number from 1 through 9. "DEL %1" tells DOS to delete the file name that was typed after the batch file name on the command line. `%0' may also be used. It is a special version. It represents the batch file name itself, unless the SHIFT command has moved other parameters into that position. For the latter, if parameters have been shifted, `%0' then acts as any other Percent-number command-line parameter.

        A single Percent sign is also used at the command line with the "FOR" command. It is followed by a single letter, although some newer DOS versions allow multiple letters.

    FOR %F IN (*.BAK) DO DELETE %F

        This tells the FOR command to look for each .bak file in the current directory and to delete it. `%F' represents each of the .bak files in turn during the delete process.


  • [ %% ] (Percent Percent or Double Percent) is employed in the "FOR" command when it is used within a batch file. It represents the variable used in that command. It is followed by a single letter, although as stated above, some newer DOS versions allow multiple letters.

    FOR %%F IN (*.BAK) DO DELETE %%F

        This same example as in the Single Percent explanation tells the FOR command to look for each .bak file in the current directory and to delete it. `%%F' represents each of the .bak files in turn during the delete process.

        The Double Percent is also used when one must direct a percent sign to another file from within a batch file:

    ECHO DEL %%1 > TEST.BAT

        When viewed, the file "TEST.bat" will show this as "%1".


  • [ % % ] (Two Percents) are used to denote a variable in most versions of DOS. One each is placed at the beginning and end of the variable name. "SET NAME=NATASHA" means that everywhere one wants to use the variable "NAME", it must be shown as "%NAME%". In this example, DOS will substitute "NATASHA" everywhere it sees the variable "%NAME%".


  • [ | ] (Pipe) This is used to pipe (direct) one program's output to another program as an input for further processing. "DIR | SORT" will send the file list generated by DIR on to the SORT command to allow it to be organised. "TYPE FILE.TXT" | XSET /LINE 1 TEXT" sends FILE.txt to XSET which looks at the first line and saves it as the variable "%TEXT%".


  • [ || ] (Double Pipe) Used by 4DOS as a special type of command separator. It is used between two commands where one wants the command following `&&' to be executed only if the first command is not successful. This will work only with a command used before `||' that returns an exit code of `1' or higher. If exit codes are employed, anything higher than `0' (zero) typically represents something other than complete success. For more on this aspect of DOS commands, see DOS Exit Codes. Also, refer to the "Double Ampersand" symbol farther back.


  • [ + ] (Plus) The COPY command uses the Plus Sign to allow files to be combined into one large one:

    COPY FILE1 + FILE2 + FILE3 BIG-FILE

    The Plus Sign is also used to invoke file attributes of Archive, Hidden, Read-Only and System via the ATTRIB command.

        `+' may be seen used in some commands' switches. The DR-DOS "SORT" command uses it to designate upon which column to base its sort via the `/+n' switch, where `n' is a number.

        The Plus key is used in DOS SHELL to expand one directory level.


  • [ . ] (Point) Erroneously referred to as a "period", this character is used as a separator between a software's main version number and its update number. An example would be DR-DOS 7.03. This would be pronounced "dee-arr doss seven point zero three". (See "Dot", farther back.)


  • [ ? ] (Question) is used by DOS as a wild card. Unlike the Asterisk, it represents a single character only. So "READ?Me.txt" means all .txt files beginning with "Read", followed by any single character and ending with "ME". Thus, it would cover "READ-ME.txt" as well as "READ_ME.txt".

        Coupled with the Forward Slash ( /? ), the Question Mark is a common switch character that will give brief help with a command or utility in most DOS versions and programs.

        A single Question Mark entered on the command line will show a list of available commands in some DOS versions.

        Another usage in some DOS versions is to allow prompting in the DOS start file, CONFIG.sys. The following line in a DR-DOS (dee-arr doss) CONFIG.sys will prompt the user as to whether to load ANSIPLUS or not:

    ?DEVICE=ANSIPLUS

        Be aware that other DOSes using this feature may require the question mark be placed elsewhere on the line.


  • [ ?? ] (Double Question) is an internal variable used by 4DOS to give the reason the last program terminated.


  • [ ' ] (Quote, Single, Right ) The Right Single Quote is used in some versions of DOS in the FOR command. Some DOS utilities use it to delimit text.


  • [ " ] (Double Quote) These are used in pairs to surround a long file name, a text string, or in batch files as part of the "IF" command.

    DELETE "MY FILE.TXT"
    FIND "DOS Version"
    IF "%1" == "OK" GOTO END

        Some versions of DELTREE can use Double Quotes to surround illegal file or directory names in order to delete them.


  • [ ; ] (Semicolon) Employed in configuration and some script languages to allow remarks (comments) to be inserted. Comments are used to instruct those reading the code about various parts of the file. Text after a Semicolon is ignored by DOS and is not executed or displayed. One may use the semicolon for this purpose in CONFIG.sys.

        This character is used to separate items in the PATH statement:

    PATH=C:\BATCH;C:\DOS;C:\UTIL

        The Semicolon is also used in ANSI "Escape" sequences to separate code strings. (See "Escape", farther back.)

        The FOR command can use the Semicolon to separate items in the set contained within the parentheses.

    FOR %N IN (1;2;3) DO ECHO %N.

        Under some DOS versions, "ECHO;" will produce a blank line on the screen.


  • [   ] (Space) DOS uses this to delimit text, and commands and their switches or parameters.

        The FOR command can use spaces, among other characters, to separate the items in the set.

    FOR %N IN (1 2 3) DO ECHO %N.

        Some DOSes could produce a blank line on screen with "ECHO   " (ECHO Space Space). However, this seems to have been retired in all versions since about the mid 1990s.


  • [ ~ ] (Tilde) (TILL-dh) (The second syllable is only lightly prononced.) A symbol to denote the missing part of a long file name when viewed on a system that only supports eight-character names.

    SPRING-BACKUP.TXT becomes SPRING~1.TXT
    SPRING-BACKUP-FINAL.TXT becomes SPRING~2.TXT


  • [ _ ] (Underscore) is used as a word separator in file names on systems that don't allow spaces: MY_FILE.TXT. (The Dash may also be used for this purpose.)

        The Underscore is also used by 4DOS in place of two percent signs to designate internal environmental variables. "_DATE" represents the current date, as an example.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值