shell script for prepending shebangs

This commit is contained in:
rasbt 2014-05-21 17:17:45 -04:00
parent f361524fea
commit 040b553a00
2 changed files with 17 additions and 1 deletions

View File

@ -38,6 +38,8 @@ Useful functions, tutorials, and other Python-related things
- Happy Mother's Day [[IPython nb]](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/funstuff/happy_mothers_day.ipynb?create=1)
**// useful snippets**
**// useful scripts snippets**
- [Shell script](./useful_scripts/prepend_python_shebang.sh) for prepending Python-shebangs to all .py files in a current directory.
- convert 'tab-delimited' to 'comma-separated' CSV files [[IPython nb]](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/useful_scripts/fix_tab_csv.ipynb?create=1)

View File

@ -0,0 +1,14 @@
# Sebastian Raschka 05/21/2014
# Shell script that prepends a Python shebang
# `!#/usr/bin/python` to all
# Python script files in the current directory
# so that script files can be executed via
# >> myscript.py
# instead of
# >> python myscript.py
find ./ -maxdepth 1 -name "*.py" -exec sed -i.bak '1i\
!#/usr/bin/python
' {} \;
find . -name "*.bak" -exec rm -rf {} \;