Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Search 32 character long directories only with find

Let say I have a directory with a lot of subdirectories:

04762b39018e3cf4b1a2c6a304919b75
06e0caf156de30dd962cf6b9300aba66
1f1d0cb1b810336299cda5426d0f12f5
2fe7a428eb303da6846800fa20ab7ed4
41e0136413703b0685d6799f8a22a8e6
asdf
1234
Databases

Some of this directories are exact 32 characters long, (md5hash actually) and I would like to find them. Recursive search is not required in this case. I tried with this command:

find /root/my/subdir -maxdepth 1 -type d -regex '^.*[a-fA-F0-9]{32}$'

and I would get result:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

04762b39018e3cf4b1a2c6a304919b75
06e0caf156de30dd962cf6b9300aba66
1f1d0cb1b810336299cda5426d0f12f5
2fe7a428eb303da6846800fa20ab7ed4
41e0136413703b0685d6799f8a22a8e6

but I didn’t get anything. In my case, I would prefer find for this, because then it is easy to pass bash commands later, but anything bash compatible one-liner will be good.

>Solution :

Depending on your version of find you might only need to turn on egrep:

$ find /root/my/subdir -maxdepth 1 -type d -regextype egrep -regex '^.*[a-fA-F0-9]{32}$'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading