bash command to get the absolute path of a file: `%~dpnx1`

i've seen this question: Get the absolute path of file in batch script

And i was searching something pretty similar. The answer written there:

"You can use %~dpnx1. which expands to the drive, path, name and extension of the first argument. Don't forget to quote the name when passing it to another command, though."

is what i want to understand. How should i use that command %~dpnx1 in my script to obtain the path of the own script is located? Or if someone know a simpler way is well accepted.

Thanks


假设你想在脚本本身运行时找到你的bash脚本的绝对路径:

dir=$( cd -P -- "$(dirname -- "$0")" && pwd -P )
链接地址: http://www.djcxy.com/p/56800.html

上一篇: 如何调试返回值的bash函数,以及如何向变量添加换行符?

下一篇: bash命令获取文件的绝对路径:`%〜dpnx1`