Bash 쉘스크립트 상대경로 얻기

Jmnote (토론 | 기여)님의 2015년 3월 11일 (수) 17:11 판 (새 문서: ;What directory a bash script file is stored in? ;Bash 파일 디렉토리 확인 ;Bash 파일 있는 폴더 확인 ==방법== <source lang='bash'> DIR=$( cd "$( dirname "${BASH_SOUR...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
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 }}