
Bash에서는 함수 호출, 스크립트 호출, 내장 명령 또는 외부 프로그램을 명령으로 실행할 수 있습니다.
반대로, 주어진 명령 이름이 함수 호출, 스크립트 호출, 내장 명령 또는 외부 프로그램인지 어떻게 알 수 있습니까?
감사해요.
답변1
내장 명령은 type
명령이 내장 명령인지, 함수인지, 외부 프로그램인지 알려줍니다.
> type locate
locate is /usr/bin/locate
> type type
type is a shell builtin
type -t
구문 분석하기 쉬운 출력을 제공합니다.
type
컴파일된 실행 파일과 스크립트 사이에는 구별이 없습니다. 그러나 주어진 이름이 외부 명령일 때마다 이를 사용하여 둘을 file
구별 할 수 있습니다.type
> file ~/bin/c
/Users/steved/bin/c: POSIX shell script text executable, ASCII text
> file /usr/bin/locate
/usr/bin/locate: Mach-O 64-bit executable x86_64