Comparison between Shell script commands and DOS batch processing commands-Linux general technology-Linux technology and application information. The following is a detailed description. [I = s] This post was last edited by lijiang at, January 10 ,.
,
In fact, the defective DOS batch processing file language can still write some powerful scripts, although they generally require external tools. therefore, in some cases, we still need to convert old DOS batch files to UNIX shell scripts. in general, it is not difficult to do this, because the DOS batch file processing operations are only a restricted subset of equivalent shell scripts.
Batch File operator Shell script equivalent symbol meaning
% $ Prefix of command line parameters
/-Command Option mark
\/Directory path Separator
===( Equal to) string comparison test
! = !! = (Unequal) string comparison test
| MPs queue
@ Set + v do not print the current command
** File name "wildcard"
> File redirection (overwrite)
>>>> File redirection (additional)
< <重定向stdin
% VAR % $ VAR environment variable
REM # comment
NOT! Invert
NUL/dev/null "black hole" is used to block command output
ECHOecho print (more options in Bash)
ECHO. echo print empty rows
ECHO OFFset + v does not print Subsequent commands
FOR % var in (LIST) DOfor var in
; Do "for" Loop
: The LABEL has no equivalence (redundant) LABEL.
GOTO has no equivalence (using a function) to jump to another location in the script.
PAUSEsleep pause or wait for a while
CHOICEcase or select
Ifififif Condition Statement
If exist FILENAMEif [-e filename] test whether the file exists
IF! % N =! If [-z "$ N"] parameter "N" exists
CALLsource command or. (dot operator) "include" another script
COMMAND/Csource COMMAND or. (dot operator) "include" another script (same as CALL)
SETexport: sets an environment variable.
SHIFTshift left shift command line parameter list
SGN-lt or-gt (integer) symbol
ERRORLEVEL $? Exit status
CONstdin "console" (stdin)
PRN/dev/lp0 (general) printing device
LPT1/dev/lp0 the first printing device
COM1/dev/ttyS0 first serial port
________________________________________
Batch files generally contain doscommands. We must convert them to UNIX equivalent commands so that we can convert the batch files into shell script files.
________________________________________
Doscommand UNIX equivalent command Effect
ASSIGNln link file or directory
ATTRIBchmod
Change CDcd directory
Change directory in CHDIRcd
CLSclear clear screen
COMPdiff, comm, cmp file comparison
COPYcp file copy
Ctl-CCtl-C interrupt (signal)
Ctl-ZCtl-DEOF (end of file)
DELrm delete file
DELTREErm-rf recursively delete directories
DIRls-l list directory content
ERASErm deletes a file
EXITexit exit the current process
Comparison of FCcomm and cmp files
FINDgrep searches for strings in the file
Create a directory in MDmkdir
MKDIRmkdir create a directory
MOREmore displays text files by PAGE
MOVEmv mobile File
PATH $ PATH: PATH of the executable file
RENmv Rename (mobile)
RENAMEmv Rename (MOVE)
RDrmdir Delete directory
RMDIRrmdir Delete directory
SORTsort sorting File
TIMEdate: displays the system time.
TYPEcat outputs the file to stdout
XCOPYcp (extended) file copy
________________________________________
In fact, almost all UNIX and shell operators and commands have many options. They are much more powerful than DOS and batch processing files. many DOS batch files rely on auxiliary tools, such as ask.com, which is a similar copy much worse than the read command. DOS supports a very limited number of file name wildcard extensions and is not complete. It only recognizes * And ?.
From Advanced Bash Script Programming Guide