title: Using wildcard and regex in find
body: <p>I want to use <code>find</code> to list specific files using wildcard or regular expression.</p>
  <p>For instance, I am currently using the following bash code to list all files starting with <code>A</code>.</p>
  <pre><code>nm=&quot;$2&quot;  # user passes wildcard &quot;A*&quot; in $nm.
  find $dir -name $nm
  </code></pre>
  <p>But one problem is that I don't want Bash to expand the wildcard being passed by the user.</p>
  <p>I constructed the following bash function</p>
  <pre><code>mse ()
  {
  
   local incl=() 
  
   local iarg=0  narg=&quot;$#&quot;
  
   IFSPREV=&quot;$IFS&quot;  # Save IFS (splits arguments on whitespace by default)
   IFS=&quot; |=&quot;         # Split arguments on &quot; &quot; and &quot;=&quot;
   set -- $*       # Set positional parameters to command line arguments
   IFS=&quot;$IFSPREV&quot;  # Set original IFS
  
   while (( $# &gt; 0  )); do
     iarg=$(( iarg + 1 ))
     case &quot;$1&quot; in
       (&quot;--incl&quot;) incl+=(&quot;$2&quot;) ; echo &quot;Test: $2&quot; ; shift 2 ;;
     esac
   done
  
   echo &quot;\$@: $@&quot;
   echo &quot;incl: ${incl[@]}&quot;
   }
  </code></pre>
  <p>Then I run the function in the terminal</p>
  <pre><code>mse -d /media/hag/hc1/a1-chaos/amvib/ --incl=&quot;A*&quot;
  </code></pre>
  <p>which gives</p>
  <pre><code>incl: Admir
  </code></pre>
  <p>The result is wrong because it is picking up the directory name <code>Admir</code> that shows up it the current working directory.</p>
  <p>And for passing regular expressions, how should the find command be constructed?</p>