title: ssh remote variable assignment?
body: <p>The following does not work for me:</p>
  
  <pre><code>ssh user@remote.server "k=5; echo $k;"
  </code></pre>
  
  <p>it just returns an empty line. </p>
  
  <p>How can I assign a variable on a remote session (ssh)?</p>
  
  <p><strong>Note:</strong> My question is <em>not</em> about how to pass local variables to my ssh session, but rather how to create and assign remote variables. (should be a pretty straight forward task?)</p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>In more detail I am trying to do this:</p>
  
  <pre><code>bkp=/some/path/to/backups
  ssh user@remote.server "bkps=( $(find $bkp/* -type d | sort) );
                          echo 'number of backups: '${#bkps[@]};
                          while [ ${#bkps[@]} -gt 5 ]; do
                              echo ${bkps[${#bkps[@]}-1]};
                              #rm -rf $bkps[${#bkps[@]}-1];
                              unset bkps[${#bkps[@]}-1];
                          done;"
  </code></pre>
  
  <p>The find command works fine, but for some reason <code>$bkps</code> does not get populated.
  So my guess was that it would be a variable assignment issue, since I think I have checked everything else...</p>