linuxbashfind

find folders in a directory, without listing the parent directory


Having trouble listing the contents of a folder I'm not in, while excluding the actual folder name itself.

ex:

root@vps [~]# find ~/test -type d
/root/test
/root/test/test1

However I want it to only display /test1, as the example.

Thoughts?


Solution

  • You can do that with -exec and basename:

    find ~/test -type d -exec basename {} \;
    

    Explanation: