title: lowering filenames from bash script, using awk as a helper
body: <p>I have the following script I wrote, for renaming files in current directory,
  using <code>awk</code></p>
  
  <pre><code>#!/bin/bash
  
  # This script collects filenames from current dir, into list
  # and then uses awk to process them, lowering their filenames
  
  [ -f ./tmp.filelist ] &amp;&amp; rm tmp.filelist
  
  for file in *
  do
      echo $file &gt;&gt; tmp.filelist
  done
  
  # if file already not all lowercase, make it lowercase
  awk '{ if ($0 != tolower($0))
          printf("mv \"%s\" \"%s\"\n", $0, tolower($0)) | "sh" }
  
          END { close("sh") }
  ' tmp.filelist &amp;&amp; rm tmp.filelist
  </code></pre>
  
  <p>Is there some better way of escaping those <code>%s</code>-es in <code>printf</code> before sending
  them to shell? I am not interested in better way of doing this, like only shell or something, I want to use <code>awk</code> here, and just asking about best way to pass filenames with spaces to shell, whatever might be the case, not just this script.</p>