<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>eel3</author_name>
  <author_url>https://blog.hatena.ne.jp/eel3/</author_url>
  <blog_title>新・日々録 by TRASH BOX@Eel</blog_title>
  <blog_url>https://eel3.hatenablog.com/</blog_url>
  <categories>
    <anon>小ネタプログラミング</anon>
    <anon>シェルスクリプト</anon>
  </categories>
  <description>シェルスクリプトを書いていて、実行時にそのスクリプト自身のパスを取得したくなった。バッチファイルでいうコレみたいな感じ。 @echo off echo %~dp0 そのスクリプトは環境変数PATHに登録されたディレクトリに置くことはなく、必ずカレントディレクトリから相対パスないし絶対パスで指定して実行する。取得するパスは相対パスで構わない。よくある方法はこんな感じだと思う。 #!/bin/sh # 相対パスでも問題ない場合 echo `dirname $0` # 確実に絶対パスで取得したい場合 echo `cd \`dirname $0\`; pwd` で、その方法を使おうとしたらdirnam…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Feel3.hatenablog.com%2Fentry%2F20130826%2F1377522419&quot; title=&quot;シェルスクリプト自身のパスを取得しようとしたらdirnameが無かったので頑張った話 - 新・日々録 by TRASH BOX@Eel&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2013-08-26 22:06:59</published>
  <title>シェルスクリプト自身のパスを取得しようとしたらdirnameが無かったので頑張った話</title>
  <type>rich</type>
  <url>https://eel3.hatenablog.com/entry/20130826/1377522419</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
