title: How to pass an asterisk(*) to a command inside a Bash script?
body: <p>I have done quite a bit of looking on Google, stackexchange, stackoverflow, etc. So far none of the examples satisfies a quite simple use case for using an asterisk character (not as a wildcard) within a bash script.</p>
  
  <p>The following command examples work exactly as needed in the (interactive) terminal window.  Both commands give the same results.</p>
  
  <pre><code>  find  /home/will/ref/  -path "*Java Develop*.pdf"
    #
    target="Java Develop"
    find  /home/will/ref/  -path "*$target*.pdf"
  </code></pre>
  
  <p>The question, and objective, is how to successfully put that command into a script with the <code>find</code> target</p>
  
  <ul>
  <li>"Java Develop"</li>
  </ul>
  
  <p>Passed as an argument?  For a script named, <code>get-ref</code> as follows.</p>
  
  <pre><code>   get-ref "Java Develop"`
  </code></pre>
  
  <p>None of the following (not the exhaustive) list of attempts:</p>
  
  <ol>
  <li><code>find  /home/will/ref/  -path \"\*$target\*.pdf\"</code></li>
  <li><code>find  /home/will/ref/  -path \"*$target*.pdf\"</code></li>
  <li><code>find  /home/will/ref/  -path "*$target*.pdf"</code></li>
  </ol>
  
  <p>Plus several variations around those examples including putting the <code>-path</code> argument string in a variable -- All so far manage to <em>split</em> the target using the space or accept the argument and return nothing.  When used on the command-line, about 3 x files are returned.</p>
  
  <p>To be clear though, I'm not concerned with the space inside <code>$target</code> because that side seems to work OK.  Ultimately the <code>$target</code> will be a script parameter anyway.</p>
  
  <p>-- <strong><em>update</em></strong> 2015-12-22 --</p>
  
  <p>It appears that the Bash version is important.  This version is:</p>
  
  <pre><code>  $ bash -version
    GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
  </code></pre>
  
  <p>A friend ran more or less the same options as above and they work.  When I ran his script on my PC, same result, no output.</p>
  
  <p>To answer the questions:</p>
  
  <ul>
  <li>Everything fails the either by not 'finding' something; or by giving an error about the string "Devel" because of mis-balance quotes we presume.</li>
  <li>I used <code>set -x</code> and the results have found an answer that work on this bash (see posted answer).  </li>
  </ul>
  
  <p>I'll just post my version as an answer; perhaps someone will have a better method or at least an explanation that lets Bash off the hook.</p>
  
  <p>The concern is that the asterisks(*) are somehow Not being seen or processed as expected when the same command is used inside a Bash script.  </p>