たとえば、私のスクリプトには次の種類のファイルパスがあります。
/path/to/some/file/../../file1.txt
readlink
そのパスを実際の物理形式に変換するために呼び出すことができるコマンドはありますか?
/path/to/file1.txt
ベストアンサー1
ああ、あまりにも急な質問ですね。 Linuxでは、スイッチreadlink
で使用するのが答えです-m
。
$ readlink -m /home/saml/web/../web_login_form_examples/basic-php-parsing.zip
/home/saml/web_login_form_examples/basic-php-parsing.zip
読み取りリンクのマニュアルページ
-m, --canonicalize-missing
canonicalize by following every symlink in every component of the
given name recursively, without requirements on components existence