Created
September 6, 2011 11:55
-
-
Save tyuki39/1197354 to your computer and use it in GitHub Desktop.
バッチファイルとシェルスクリプトの雑多な例4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
IF "%EA%"=="VA" IF %EB%=="VB" ( | |
ECHO EA == VA AND EB == VB | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$EA" = "VA" -a "$EB" = "VB" ]; then | |
echo EA == VA AND EB == VB | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
IF "%EA:VA=%_%EB:VB=%"=="_" ( | |
ECHO EA == VA AND EB == VB | |
) | |
IF "%EA:VA=%_%EB:VB=%"=="%EA%_" ( | |
ECHO EA != VA AND EB == VB | |
) | |
IF "%EA:VA=%_%EB:VB=%"=="_%EB%" ( | |
ECHO EA == VA AND EB != VB | |
) | |
IF "%EA:VA=%_%EB:VB=%"=="%EA%_%EB%" ( | |
ECHO EA != VA AND EB != VB | |
) | |
IF NOT "%EA:VA=%_%EB:VB=%"=="%EA%_%EB%" ( | |
ECHO EA == VA OR EB == VB | |
) | |
IF NOT "%EA:VA=%_%EB:VB=%"=="_%EB%" ( | |
ECHO EA != VA OR EB == VB | |
) | |
IF NOT "%EA:VA=%_%EB:VB=%"=="%EA%_" ( | |
ECHO EA == VA OR EB != VB | |
) | |
IF NOT "%EA:VA=%_%EB:VB=%"=="_" ( | |
ECHO EA != VA OR EB != VB | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$EA" = "VA" -a "$EB" = "VB" ]; then | |
echo EA == VA AND EB == VB | |
fi | |
if [ "$EA" != "VA" -a "$EB" = "VB" ]; then | |
echo EA != VA AND EB == VB | |
fi | |
if [ "$EA" = "VA" -a "$EB" != "VB" ]; then | |
echo EA == VA AND EB != VB | |
fi | |
if [ "$EA" != "VA" -a "$EB" != "VB" ]; then | |
echo EA != VA AND EB != VB | |
fi | |
if [ "$EA" = "VA" -o "$EB" = "VB" ]; then | |
echo EA == VA OR EB == VB | |
fi | |
if [ "$EA" != "VA" -o "$EB" = "VB" ]; then | |
echo EA != VA OR EB == VB | |
fi | |
if [ "$EA" = "VA" -o "$EB" != "VB" ]; then | |
echo EA == VA OR EB != VB | |
fi | |
if [ "$EA" != "VA" -o "$EB" != "VB" ]; then | |
echo EA != VA OR EB != VB | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SET DUMMY=!X | |
IF NOT "%DUMMY%"=="X" ( | |
ECHO NEED "SETLOCAL ENABLEDELAYEDEXPANSION" | |
EXIT /B 1 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
IF %ERRORLEVEL% EQU 0 ( | |
ECHO OF | |
ELSE IF %ERRORLEVEL% EQU 1 ( | |
ECHO ERROR1 | |
ELSE IF %ERRORLEVEL% EQU 2 ( | |
ECHO ERROR2 | |
ELSE ( | |
ECHO UNKNOWN ERROR | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ $? -eq 0 ]; then | |
echo OK | |
elif [ $? -eq 1 ]; then | |
echo ERROR1 | |
elif [ $? -eq 2 ]; then | |
echo ERROR2 | |
else | |
echo UNKNOWN ERROR | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
SET SUM=0 | |
FOR %%i IN (1 2 3 4 5 6 7 8 9 10) DO ( | |
SET /A SUM=%SUM% + %%i | |
) | |
ECHO %SUM% | |
SET SUM=0 | |
FOR %%i IN (1 2 3 4 5 6 7 8 9 10) DO ( | |
SET /A SUM=!SUM! + %%i | |
) | |
ECHO %SUM% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUM=0 | |
for i in 1 2 3 4 5 6 7 8 9 10; do | |
SUM=`expr $SUM + $i` | |
done | |
echo $SUM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment