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

(새 문서: ;What directory a bash script file is stored in? ;Bash 파일 디렉토리 확인 ;Bash 파일 있는 폴더 확인 ==방법== <source lang='bash'> DIR=$( cd "$( dirname "${BASH_SOUR...)
 
7번째 줄: 7번째 줄:
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd  
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd  
</source>
</source>
;실행예시
<source lang='cli'>
<source lang='cli'>
[root@zetawiki ~]# cat /tmp/test.sh  
[root@zetawiki ~]# cat /tmp/test.sh  

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

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 }}