1 |
$(cd $(dirname $0); pwd) |
動作確認
test.sh
1 2 3 4 |
<span class="c">#!/bin/sh</span> <span class="nv">DIR</span><span class="o">=</span><span class="si">$(</span><span class="nb">cd</span> <span class="si">$(</span><span class="nb">dirname</span> <span class="nv">$0</span><span class="si">)</span><span class="p">;</span> <span class="nb">pwd</span><span class="si">)</span> <span class="nb">echo</span> <span class="k">${</span><span class="nv">DIR</span><span class="k">}</span> |
1 2 3 4 5 |
$ ls -l /home/yuta/test.sh -rw-rw-rw- 1 yuta yuta 54 Sep 10 16:10 /home/yuta/test.sh $ sh test.sh /home/yuta |