title: bash - Pipe output from ls to rsync
body: <p>I'm trying to use <code>rsync</code> to backup folders containing a certain word, using <code>ls</code>, <code>grep</code> and <code>rsync</code>. However <code>rsync</code> does not seem to accept output from <code>grep</code> as input. I've tried the following:</p>
  
  <pre><code>$ ls -d $PWD/** | grep March | rsync -av 'dst'
  </code></pre>
  
  <p>This does nothing really, even though using just <code>ls -d $PWD/** | grep March</code> produces exactly the list of folders I want to move. </p>
  
  <pre><code>$ ls -d $PWD/** | grep March | xargs -0 | rsync -av 'dst'
  $ ls -d $PWD/** | grep March | xargs -0 echo | rsync -av 'dst'
  $ ls -d $PWD/** | grep March | xargs -0 rsync -av 'dst'
  </code></pre>
  
  <p>Many(including <code>dst</code>, here I escape space with <code>\</code>) of the folders contains spaces I thought that might cause problems and found <code>xargs</code> might be of help, but still doesn't move anything. </p>
  
  <p>I have tried the above with <code>sudo</code>, the <code>-avu</code>option for <code>rsync</code> and <code>-r</code> even though this i included in the <code>-a</code>option. I usually use the <code>--dry-run</code> option for <code>rsync</code> but I've also tried without. What am I doing wrong? 
  Is it possible to pipe input to <code>rsync</code> like this?</p>
  
  <p>I'm on OSX 10.13.3. GNU bash, version 3.2.57(1)</p>
  
  <p>Thank you.</p>