开发者

How to get part of path using linux commands

开发者 https://www.devze.com 2023-03-28 08:52 出处:网络
Need get part开发者_如何学编程 of path, for example \"/home/server/folder1/rev.1111/bin\" Needed part is \"rev.1111\"

Need get part开发者_如何学编程 of path, for example "/home/server/folder1/rev.1111/bin" Needed part is "rev.1111" I`ll try to parse by PWD & grep commands, but I am newbie on linux and I cant do this.


pwd | awk -F/ '{print $(NF-1)}'


Using the basename & dirname commands:

basename $(dirname $(pwd))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号