复制文件以保留文件夹结构 [英] Copy files preserving folder structure

查看:116
本文介绍了复制文件以保留文件夹结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我制作一个shell脚本来:

Could anyone help me to make a shell script to:

具有一定的文件夹和子文件夹结构,将从给定日期(或几天后)起修改的所有文件从其复制到其他位置,并始终保留文件夹结构.

Having a certain folders and subfolders structure, copy from it to some other location all the files modified from a given date (or from a number of days on) and always preserving the folder structure.

因此,结果将是仅具有与修改后的日期条件匹配的文件的原点的子集.无需将这个新的子集放置在任何远程位置,只需将另一个文件夹放置在同一文件系统中即可.

So the result would be a subset of the origin having only the files that match the modified date condition. No need to place this new subset in any remote location... just another folder in the same file system.

有什么想法吗?

我可以想到一些手动方法,但是如果还有一些自动"方法,我想知道.

I can think of some manual methods, but if there were something more "automatic", I'd like to know.

非常感谢

推荐答案

您可以使用以下脚本:

#!/bin/bash
mkdir -p "$2" && find . -type f ! -mtime +$1 | tar -cT - -f - |tar -C "$2" -xf -

用法:

copyscript <not-older-than-N-days> <destination dir>

这篇关于复制文件以保留文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆