我想将文件夹中的所有文件从x天以上复制到新路径。
源文件夹结构:
/opt/install/sw1/team/p2.csv
/opt/install/sw2/team/p2.csv
目的地应为:
/work/backup/sw1/team/p2.csv
/work/backup/sw2/team/p2.csv
答案 0 :(得分:1)
这样做:
mkdir /work/backup/sw1/team
find /opt/install/sw1/team -maxdepth 0 -mtime +5 -exec cp '{}' /work/backup/sw1/team \;
mkdir /work/backup/sw2/team
find /opt/install/sw2/team -maxdepth 0 -mtime +5 -exec cp '{}' /work/backup/sw2/team \;
答案 1 :(得分:0)
如果我理解正确:
cp -a /opt/install/sw1 /opt/install/sw2
或者为了详细:
cp -av /opt/install/sw1 /opt/install/sw2
-a
表示要复制所有内容并保留权限。如果这不是您想要的,那么-r
可能更合适。