Created
September 6, 2011 11:30
-
-
Save tyuki39/1197317 to your computer and use it in GitHub Desktop.
バッチファイルとシェルスクリプトの雑多な例3
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 | |
dir *.existent > nul |
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
ls *.existent > /dev/null |
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
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
exit 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 | |
ECHO INPUT: | |
SET /P input= |
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 INPUT: | |
read input |
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 | |
dir *.existent > result1.txt | |
dir /y *.existent >> result1.txt | |
dir *.existent 2> result2.txt | |
dir /y *.existent 2>> result2.txt | |
dir *.existent > result3.txt 2>&1 | |
dir /y *.existent >> result3.txt 2>&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
ls *.existent > result1.txt | |
ls -y *.existent >> result1.txt | |
ls *.existent 2> result2.txt | |
ls -y *.existent 2>> result2.txt | |
ls *.existent > result3.txt 2>&1 | |
ls -y *.existent >> result3.txt 2>&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 | |
CALL :SUBROUTINE 0 OK | |
CALL :SUBROUTINE 1 NG | |
EXIT /B | |
:SUBROUTINE | |
IF NOT %1==0 ( | |
ECHO %2 | |
EXIT /B %1 | |
) | |
EXIT /B 0 |
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
subroutine() { | |
if [ $1 -ne 0 ]; then | |
echo $2 | |
return $1 | |
fi | |
return 0 | |
} | |
subroutine 0 "OK" | |
subroutine 1 "NG" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment