"$?" - Y-in-Y/inyang GitHub Wiki
'$?'
Expands to the exit status of the most recently executed foreground pipeline.
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ $?
bash: 0: command not found
-> 이전에 정상종료됐을 경우 "0" ;
bash-3.2$ $?
bash: 0: command not found
bash-3.2$ $?
bash: 127: command not found
-> 이전 명령의 에러메시지가 Command not found 였을 경우 "127" ;
bash-3.2$ <
bash: syntax error near unexpected token `newline'
bash-3.2$ $?
bash: 258: command not found
-> 이전 명령의 에러메시지가 Syntax error near unexpected token 'newline'일 경우 258 ;
bash-3.2$ ls a
ls: a: No such file or directory
bash-3.2$ $?
bash: 1: command not found
-> 이전 명령의 에러메시지가 No such file or directory 일 경우 1 ;
bash-3.2$ cat -e
dsjaflie
dsjaflie$
^\Quit: 3
bash-3.2$ $?
bash: 131: command not found
bash-3.2$ cat
tes^\Quit: 3 //tes 를 치다가 ctrl + \ 한 경우
bash-3.2$
bash-3.2$ $?
bash: 131: command not found
-> ctrl + \ 로 종료시켰을 경우 131 ;
bash-3.2$ cat -e
sjfia;l
sjfia;l$
^C
bash-3.2$ $?
bash: 130: command not found
-> ctrl + C 로 종료시켰을 경우 130 ;
bash-3.2$ cat -e
dkfsj;aohf
dkfsj;aohf$
bash-3.2$ $?
bash: 0: command not found
-> ctrl + D 로 종료시켰을 경우 0 ;