I like Python, even for shell scripting. I can't really figure out how to use sed
, so I stick to Python's search and replace:
#!/usr/bin/env python
import os, glob
for filename in glob('xxx_*.in'):
os.rename(filename , filename .replace('abc', 'def'))
So as an inline script which runs when you copy/paste it into Terminal (I don't have Python on my current machine, so no guarantees),
python -c "import os, glob; eval('for f in glob(\'xxx_*.in\'):\n os.rename(filename , filename .replace(\'abc\', \'def\'))'"
It seems like you meant the file's contents. That, I can do without Python (hopefully this works):
for f in xxx_*.in; do sed s/abc/def/g "$f"; done