We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f361524 commit 040b553Copy full SHA for 040b553
2 files changed
README.md
@@ -38,6 +38,8 @@ Useful functions, tutorials, and other Python-related things
38
- Happy Mother's Day [[IPython nb]](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/funstuff/happy_mothers_day.ipynb?create=1)
39
40
41
-**// useful snippets**
+**// 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.
44
45
- 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)
useful_scripts/prepend_python_shebang.sh
@@ -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