title: How to scp all files (or select files) in a bash script
body: <p>I am trying to write a bash script where I can upload all files (or ones that I name) in a current directory to a server using <code>scp</code>. The following command works in a bash script.</p>
  
  <pre><code>scp * username2@destination_host:directory2/filename2
  </code></pre>
  
  <p>However, I am trying to allow my script to either name a file (and eventually several files) or upload all files, a server, and a directory in my server. Why doesn't the following script work when inputting <code>*</code> as the first argument?</p>
  
  <pre><code>scp $1 $2:$3
  </code></pre>
  
  <p>When trying to upload a C++ project by using <code>*</code> in the current directory, it tells me: </p>
  
  <blockquote>
    <p>ssh: Could not resolve hostname main.cpp: Name or service not known</p>
  </blockquote>
  
  <p>If I just specify the file main.cpp it works fine, but for situations like this I don't want to have to specify the name of each file, as this could take a while for bigger projects.</p>
  
  <p>Also, a side note, how could I allow a script like this to be able to specify a variable number of files and still have it be able to recognize my server name (for example, uploading 2 files or 5 that I specify as opposed to using *)?</p>