Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 418
altern Avatar asked Nov 25 '25 08:11

altern


1 Answers

few ways with GNU find

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

$ find /path -type d -printf "%f\n" | awk 'length==33'
like image 67
ghostdog74 Avatar answered Nov 27 '25 00:11

ghostdog74



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!