2012-12-02 5 views
0

$가 발생했습니다. 내가 쓴 쉘 스크립트 중 하나에서 (나에 의해 작성되지 않은) 통합 작업.

이전 명령의 리턴 코드를 의미하는지 확인하고 싶습니다.

사용은 마지막으로 실행 된 명령의 종료 상태

runSomeCommand $VAR1 $VAR2 $VAR3 

processResult $? 
+1

가능한 복제본은 무엇입니까? 쉘 스크립트에서 의미?] (http://stackoverflow.com/questions/12741710/what-does-mean-in-a-shell-script) – devnull

+0

[링크] (http : //www.tutorialspoint .com/unix/unix-special-variables.htm) 아니면 내 대답은 http://stackoverflow.com/a/26866587/1920536 – biolinh

답변

5

$? 같은입니다.

ls 
.... 
echo $? 
0 

$ ls notexistingfile 
ls: cannot access notexistingfile: No such file or directory 

echo $? 
2 
+0

덕분에, 내 가정은 내가 확인하고 싶은 것이 었습니다. – amphibient

+3

'man bash' +'/ \?' –

관련 문제