http://tldp.org/LDP/abs/html/dosbatch.html
http://tldp.org/LDP/abs/html/external.html
http://tldp.org/LDP/abs/html/basic.html
http://tldp.org/LDP/abs/html/dosbatch.html
Table N-1. Batch file keywords / variables / operators, and their shell equivalents
Batch File Operator | Shell Script Equivalent | Meaning |
---|---|---|
% | $ | command-line parameter prefix |
/ | - | command option flag |
\ | / | directory path separator |
== | = | (equal-to) string comparison test |
!==! | != | (not equal-to) string comparison test |
| | | | pipe |
@ | set +v | do not echo current command |
* | * | filename "wild card" |
> | > | file redirection (overwrite) |
>> | >> | file redirection (append) |
< | < | redirect stdin |
%VAR% | $VAR | environmental variable |
REM | # | comment |
NOT | ! | negate following test |
NUL | /dev/null | "black hole" for burying command output |
ECHO | echo | echo (many more option in Bash) |
ECHO. | echo | echo blank line |
ECHO OFF | set +v | do not echo command(s) following |
FOR %%VAR IN (LIST) DO | for var in [list]; do | "for" loop |
:LABEL | none (unnecessary) | label |
GOTO | none (use a function) | jump to another location in the script |
PAUSE | sleep | pause or wait an interval |
CHOICE | case or select | menu choice |
IF | if | if-test |
IF EXIST FILENAME | if [ -e filename ] | test if file exists |
IF !%N==! | if [ -z "$N" ] | if replaceable parameter "N" not present |
CALL | source or . (dot operator) | "include" another script |
COMMAND /C | source or . (dot operator) | "include" another script (same as CALL) |
SET | export | set an environmental variable |
SHIFT | shift | left shift command-line argument list |
SGN | -lt or -gt | sign (of integer) |
ERRORLEVEL | $? | exit status |
CON | stdin | "console" (stdin) |
PRN | /dev/lp0 | (generic) printer device |
LPT1 | /dev/lp0 | first printer device |
COM1 | /dev/ttyS0 | first serial port |
Table N-2. DOS commands and their UNIX equivalents
DOS Command | UNIX Equivalent | Effect |
---|---|---|
ASSIGN | ln | link file or directory |
ATTRIB | chmod | change file permissions |
CD | cd | change directory |
CHDIR | cd | change directory |
CLS | clear | clear screen |
COMP | diff, comm, cmp | file compare |
COPY | cp | file copy |
Ctl-C | Ctl-C | break (signal) |
Ctl-Z | Ctl-D | EOF (end-of-file) |
DEL | rm | delete file(s) |
DELTREE | rm -rf | delete directory recursively |
DIR | ls -l | directory listing |
ERASE | rm | delete file(s) |
EXIT | exit | exit current process |
FC | comm, cmp | file compare |
FIND | grep | find strings in files |
MD | mkdir | make directory |
MKDIR | mkdir | make directory |
MORE | more | text file paging filter |
MOVE | mv | move |
PATH | $PATH | path to executables |
REN | mv | rename (move) |
RENAME | mv | rename (move) |
RD | rmdir | remove directory |
RMDIR | rmdir | remove directory |
SORT | sort | sort file |
TIME | date | display system time |
TYPE | cat | output file to stdout |
XCOPY | cp | (extended) file copy |
sztom
osoft@qq.com
CC-BY-NC-SA