Shebang
간혹 리눅스, 유닉스 타입의 쉘스크립트 파일(.sh)을 보면 #! 으로 시작하는 코멘트라인을 볼 수 있습니다. 최상단에 위치하고 있지요. 이런것을 Shebang이라고 합니다. 간단하게 알아봅시다.
Shebang
위키피디아에서 정의를 한번 봅시다.
In computing, a shebang (also called a sha-bang, hashbang, pound-bang, or hash-pling), is the character sequence consisting of the characters number sign and exclamation mark (that is, "#!") at the beginning of a script.
Wikipedia - Shebang(Unix)
전산학에서 shebang(또한 sha-bang, hashbang, pound-bang, hash-pling)은 스크립트의 시작 부분에서 캐릭터 넘버 사인과 느낌표(exclamation mark)로 구성된 문자열을 말합니다. 예를 들자면 #!가 되겠네요.
예제
자, 실제로 어떻게 쓸까요?
#!/bin/sh
스크립트 파일의 최상단에 위처럼 선언하면 됩니다. 그러면 하위 쉘스크립트 코드를 실행하기 전에 먼저 /bin/sh이라는 프로그램을 먼저 로드합니다. 그리고 이어진 코드를 실행합니다.