Skip to content

Instantly share code, notes, and snippets.

@youngbrioche
Created December 2, 2011 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youngbrioche/1423033 to your computer and use it in GitHub Desktop.
Save youngbrioche/1423033 to your computer and use it in GitHub Desktop.
Add encoding headers to Ruby files
find -name "*.rb" | \
while read filepath; do \
{ echo -n "$filepath: "; head -n1 "$filepath"; } | \
grep -v encoding | sed -e "s#.*#$filepath#"; \
done | \
while read filepath; do \
{ echo "# encoding: UTF-8"; echo; } | \
cat - "$filepath" > "$filepath.tmp"; \
mv "$filepath.tmp" "$filepath"; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment