# Regular Expression for Random pattern

**URL:** <https://community.unix.com/t/regular-expression-for-random-pattern/270143>\
**Category:** Shell Programming and Scripting\
**Created:** [July 23, 2010, 10:47am UTC](https://community.unix.com/t/regular-expression-for-random-pattern/270143 "2010-07-23T10:47:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep\_Kr](https://community.unix.com/letter_avatar/pradeep_kr/32/6_22734026db12803ebb3e059622ac3534.png) [@Pradeep\_Kr](https://community.unix.com/u/Pradeep_Kr)\
**Post date:** [July 23, 2010, 10:47am UTC](https://community.unix.com/t/regular-expression-for-random-pattern/270143/1 "2010-07-23T10:47:01Z")

</div>

What would be the regular expression that can search for a Pattern, having 8 characters out of which atleast 1 digit, 1 lower case, 1 upper case letter and 1 special character must be there. But these can occur at any place randomly. Please help me out.  
I'm using find $dir -name "\*.txt" -exec egrep -ni "[a-z]+[A-Z]+[0-9]+['\~', '\!', '\$', '\%', '\^', '\&', '\-', '\=',' \.', '\:', '\;']" {} \; -print  
But this is working only for pattern that begins with lower then upper then digit and then special characters. What if they can happen at any random place... 😕  
Thanks in advance...🙂
