Skip to content

Instantly share code, notes, and snippets.

@ih4cku
Created July 10, 2015 14:36
Show Gist options
  • Save ih4cku/eec4ff028e6e4e1b0bc7 to your computer and use it in GitHub Desktop.
Save ih4cku/eec4ff028e6e4e1b0bc7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import sys
from os import path
script_dir = '/opt/rnnlib-utils'
scripts = os.walk(script_dir).next()[2]
for sc in scripts:
sc = path.join(script_dir, sc)
if sc.endswith('.sh'):
sb = '#! /bin/bash'
elif sc.endswith('.py'):
sb = '#!/usr/bin/env python'
else:
continue
print 'processing', sc
with open(sc) as f:
codes = f.readlines()
if codes[0].strip() != sb:
codes.insert(0, sb+'\n')
with open(sc, 'w') as f:
f.writelines(codes)
print 'done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment