Skip to content
Advertisement

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?

Advertisement

Answer

few ways with GNU find

$ find . -type d -name "?????????????????????????????????"

$ find /path -type d -printf "%fn" | awk 'length==33'
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement