简体   繁体   English

Shell脚本子目录计算

[英]Shell scripting-subdirectories calculation

Write a shell script takes the name a path (eg: /afs/andrew/course/15/123/handin), and counts all the sub directories (recursively). 编写一个shell脚本时,将名称命名为路径(例如:/ afs / andrew / course / 15/123 / handin),并计算所有子目录(递归)。

Ex. 例如 /afs/andrew/course/15/123/handin should give me 6. I tried with the Find command,but the path which i am giving is being accepted. / afs / andrew / course / 15/123 / handin应该给我6.我尝试了Find命令,但是我给的路径被接受了。

simple AWK can do that 简单的AWK可以做到

root@freebsd:~ # echo /afs/andrew/course/15/123/handin | awk -F / '{ print NF-1}'
6
root@freebsd:~ #

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM