In a file test.py
which reads:
#!/usr/bin/env python
import os
import glob
for f in glob.glob('*.txt'):
print f
...I'd like to programatically replace:
glob.glob('*.txt')
... with:
glob.glob('*.txt')+glob.glob('*.dat')
using sed
.
I have tried:
sed -i "s,glob.glob('*.txt'),glob.glob('*.txt')+glob.glob('*.dat'),g" test.py
...however this does not replace the string. I have a hunch that this has to do with the use of single quotes in the string to replace and/or the interpretation of the various quotation marks in the shell itself (bash). What is going wrong?