Skip to content

Instantly share code, notes, and snippets.

@buxx
Created March 2, 2017 21:09
Show Gist options
  • Save buxx/b85420dd10c67f0cb3ca8b939b5feb8c to your computer and use it in GitHub Desktop.
Save buxx/b85420dd10c67f0cb3ca8b939b5feb8c to your computer and use it in GitHub Desktop.
Add utf8 info usage at beginning of python file given as 1rst arg
#!/bin/bash
line=$(head -n 1 $1)
# need to be fixed below
if ! [ $line="# coding: utf-8" ]; then
printf '%s\n' "# coding: utf-8" | cat - $1 > $1.n && mv $1.n $1
fi;
# use like:
# find -iname '*.py' ! -path "./venv3.5/*" -exec ./u.sh {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment