[英]BASH: batch rename files with infix
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. 我有要重命名为'/my/file_ABC{01..10}.mat'
文件'/my/file_{01...10}.mat'
,因此'file_01.mat'
变为'file_ABC01.mat', 'file_02.mat' > 'file_ABC02.mat',...
等。
I've found a number of ways to append strings in a script but nothing (that I understand) to infix strings. 我发现了许多在脚本中附加字符串的方法,但没有(据我所知)可以插入字符串。 Suggestions? 有什么建议吗? Thanks! 谢谢!
应该这样做:
for f in /my/file_*.mat; do mv $f ${f/_/_ABC}; done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.