Search code examples
linuxunixfindname-length

How to find directories with the name of specific length


How could I find directories with the name of specific length? For example, I have bunch of directories which have length of the name equal to 33 chars ('a92e8cc611fdebcca3cf2fc8dc02c918', 'c442fb3f46d6c8bd17d27245290a9512' and so on). Does find utility accepts condition in form of the 'wc -c'? Or maybe some other utilities should be piped together?


Solution

  • few ways with GNU find

    $ find . -type d -name "?????????????????????????????????"
    
    $ find /path -type d -printf "%f\n" | awk 'length==33'