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

1 Response to “Batch file keywords / variables / operators, and their shell equivalents”

  1. 1 Bridgette July 22, 2013 at 2:24 pm

    Great goods from you, man. I’ve understand your stuff previous to and you’re just extremely
    great. I actually like what you have acquired here, certainly like what you are stating and the way in which you say it.
    You make it entertaining and you still care for to keep it sensible.
    I can not wait to read much more from you.
    This is actually a tremendous web site.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: