title: Replacement for chmod --reference on OS X?
body: <p>I'm trying to port some jenkins bash scripts from Ubuntu to OS X. The linux (and I think it is originally GNU) chmod has a --reference option that allows copying the mode from a reference file. I am looking for the equivalent code for OS X, preferably without installing extra packages. Even better would be a cross-platform solution.</p>
  
  <p>The concrete snippet:</p>
  
  <pre><code># expand all the templates
  find "$OUTPUT_PATH" -name "*.template" | while read FILE ; do
      sed \
          -e "s/%{NAME}/$OPTION_NAME/g" \
          -e "s/%{TITLE}/$OPTION_TITLE/g" \
          -e "s/%{VERSION}/$OPTION_VERSION/g" \
          -e "s/%{WHEN}/$OPTION_WHEN/g" \
              "$FILE" &gt; "${FILE%.*}"
      chmod --reference="$FILE" "${FILE%.*}"
      rm -f "$FILE"
  done
  </code></pre>
  
  <p>[edit] The combination of stat -r with saving the file mode is the right combination, stat -c doesn't exist on OS X</p>