Use GNU find to show only the leaf directories

前端 未结 7 675
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 18:57

I\'m trying to use GNU find to find only the directories that contain no other directories, but may or may not contain regular files.

My best guess so far has been:

7条回答
  •  盖世英雄少女心
    2020-12-04 19:42

    What about this one ? It's portable and it doesn't depend on finnicky linking counts. Note however that it's important to put root/folder without the trailing /.

    find root/folder -type d | awk '{ if (length($0)

提交回复
热议问题