我想复制(或移动)一些文件,例如cp ./patt*.py /other/path
.但是/other/path/
已经包含具有相同名称的文件。所以,我想复制并重命名(例如添加一些后缀):
./pattfoo.py - copy to - /other/path/pattfoo.py_other
./pattbar.py - copy to - /other/path/pattbar.py_other
./pattfur.py - copy to - /other/path/pattfur.py_other
etc.
完成任务的最简单方法是什么?
答案1
rsync -v --backup --suffix=something ./patt*.py /other/path
答案2
cd <old_path>
rename "s/.py/.py.rename/" *.py
mv *.py.rename <new_path>