查找当前路径的深度 [英] Find the depth of the current path

查看:51
本文介绍了查找当前路径的深度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写Shell脚本来查找当前路径的深度?

How can I write a shell script to find the depth of the current path?

假设我在:

/home/user/test/test1/test2/test3

它应该返回6.

推荐答案

鱼的简单方法:

count (string split / $PWD)

这篇关于查找当前路径的深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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