title: How to ignore xargs commands if stdin input is empty?
body: <p>Consider this command:</p>
  
  <pre><code>ls /mydir/*.txt | xargs chown root
  </code></pre>
  
  <p>The intention is to change owners of all text files in <code>mydir</code> to root</p>
  
  <p>The issue is that if there are no <code>.txt</code> files in <code>mydir</code> then xargs thows an error saying there is no path specified. This is a harmless example because an error is being thrown, but in some cases, like in the script that i need to use here, a blank path is assumed to be the current directory. So if I run that command from <code>/home/tom/</code> then if there is no result for <code>ls /mydir/*.txt</code> and all files under <code>/home/tom/</code> have their owners changed to root.</p>
  
  <p>So how can I have xargs ignore an empty result?</p>