Skip to content

Commit 040b553

Browse files
committed
shell script for prepending shebangs
1 parent f361524 commit 040b553

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Useful functions, tutorials, and other Python-related things
3838
- Happy Mother's Day [[IPython nb]](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/funstuff/happy_mothers_day.ipynb?create=1)
3939

4040

41-
**// useful snippets**
41+
**// useful scripts snippets**
42+
43+
- [Shell script](./useful_scripts/prepend_python_shebang.sh) for prepending Python-shebangs to all .py files in a current directory.
4244

4345
- 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)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Sebastian Raschka 05/21/2014
2+
# Shell script that prepends a Python shebang
3+
# `!#/usr/bin/python` to all
4+
# Python script files in the current directory
5+
# so that script files can be executed via
6+
# >> myscript.py
7+
# instead of
8+
# >> python myscript.py
9+
10+
find ./ -maxdepth 1 -name "*.py" -exec sed -i.bak '1i\
11+
!#/usr/bin/python
12+
' {} \;
13+
14+
find . -name "*.bak" -exec rm -rf {} \;

0 commit comments

Comments
 (0)