加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash获取当前目录的父目录

发布时间:2020-12-15 16:48:16 所属栏目:安全 来源:网络整理
导读:如果我有一个文件路径 /home/smith/Desktop/Test/home/smith/Desktop/Test/ 如何更改字符串,以便它将获得父目录? 例如 /home/smith/Desktop/home/smith/Desktop/ dir=/home/smith/Desktop/Testparentdir="$(dirname "$dir")" 如果有一个尾部斜线,也可以。
如果我有一个文件路径
/home/smith/Desktop/Test
/home/smith/Desktop/Test/

如何更改字符串,以便它将获得父目录?

例如

/home/smith/Desktop
/home/smith/Desktop/
dir=/home/smith/Desktop/Test
parentdir="$(dirname "$dir")"

如果有一个尾部斜线,也可以。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读