从路径中提取目录 [英] Extract directory from path

查看:65
本文介绍了从路径中提取目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的脚本中,我需要使用的文件的目录.例如,文件 = "stuff/backup/file.zip" .我需要一种从变量$file获取字符串" stuff/backup/"的方法.

In my script I need the directory of the file I am working with. For example, the file="stuff/backup/file.zip". I need a way to get the string "stuff/backup/" from the variable $file.

推荐答案

dirname $file

是您要寻找的

这篇关于从路径中提取目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆