如何转换" .."在bash脚本路径名绝叫什么名字? [英] How to convert ".." in path names to absolute name in a bash script?
本文介绍了如何转换" .."在bash脚本路径名绝叫什么名字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何到 ..
转换的路径名绝对路径名在bash脚本。也就是说,如果我有一个路径 /家庭/ nohsib / DVC /../ BOP
,我想这是改变的路径,而不在它的点,在这种情况下, /家庭/ nohsib / BOP
How to convert the ..
in the path names to absolute path names in a bash script. That is, if I have a path /home/nohsib/dvc/../bop
, I want this to be changed to the path without dots in it, in this case /home/nohsib/bop
我怎么能这样做?
推荐答案
什么是你正在寻找的 <$c$c>readlink$c$c>:
absolute_path=$(readlink -m /home/nohsib/dvc/../bop)
的请注意:的你需要使用GNU的的readlink
实现,它提供了-m选项。 BSD的的readlink
如没有。
Please note: You need to use GNU's readlink
implementation which offers the "-m" option. BSD's readlink
for example does not.
这篇关于如何转换&QUOT; ..&QUOT;在bash脚本路径名绝叫什么名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文