"Bash 쉘스크립트 상대경로 얻기"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
;What directory a bash script file is stored in?
;What directory a bash script file is stored in?
;Bash 파일 디렉토리 확인
;Bash 파일 현재 디렉토리 확인
;Bash 파일 있는 폴더 확인
;Bash 파일 있는 폴더 확인



2015년 3월 11일 (수) 17:13 판

What directory a bash script file is stored in?
Bash 파일 현재 디렉토리 확인
Bash 파일 있는 폴더 확인

1 방법

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
실행예시
[root@zetawiki ~]# cat /tmp/test.sh 
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
echo $DIR
[root@zetawiki ~]# sh /tmp/test.sh
/tmp

2 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}