-1

I have files '/my/file_{01...10}.mat' that I'd like to rename to '/my/file_ABC{01..10}.mat' such that 'file_01.mat' becomes 'file_ABC01.mat', 'file_02.mat' > 'file_ABC02.mat',... and so on.

I've found a number of ways to append strings in a script but nothing (that I understand) to infix strings. Suggestions? Thanks!

common_currency
  • 141
  • 1
  • 1
  • 5

1 Answers1

4

This should do it:

for f in /my/file_*.mat; do mv $f ${f/_/_ABC}; done
John Bollinger
  • 160,171
  • 8
  • 81
  • 157