linux复制文件并修改文件名

时间:2022-06-02 18:27:09

#!/bin/bash

#复制/casnw/backup/db203oradata/目录下的所有后缀名为dmp的文件拷贝到/casnw/backup/dbmonthbak 目录下
cp -f /casnw/backup/db203oradata/*.dmp /casnw/backup/dbmonthbak

#将/casnw/backup/dbmonthbak/目录下以20开头的所有文件改为以db203开头
for fname in /casnw/backup/dbmonthbak/20*
do
  mv $fname ${fname/20/db203}
done