Windows and LInux Shell Script Operators

DOS Operator UNIX or Bash Operator Description
@
ECHO OFF
set +v Set verbose mode off. -v: Echo each line of shell script as it is executed.
% $ command line argument prefix. DOS: %1 Bash: $1 for firs argument.
REM # Comment. (Not processed.)
== = string "equal to" comparison
!==! != string "not equal to" comparison
NOT ! negative of test expression
CHOICE case case/switch statement
IF

IF EXIST C:\filename

IF NOT EXIST C:\filename

if [[ test-resulting-in-bool ]];
then
...
elif ...;
then
...
else
...
fi

if [ -e /dir/filename ];
then

if [ ! -e /dir/filename ];
then

if-test

If file exists

If file does not exist.

GOTO ABC
...
:ABC
goto ABC
...
:ABC
Branch
FOR ... IN ... DO

FOR %%fff IN (C:\dir\*.*)
DO echo %%fff

for ffiillee in lliisstt;
do ...;
done

for (( expr1; expr2; expr3; ))
do ...;
done

For loop
ERRORLEVEL $? exit status/return code
PAUSE sleep sleep for specified interval

via http://www.yolinux.com

Labels: