[英]Copy a directory structure and only touch the copied files
I want to mimic copying a directory structure recursively (as in cp -r
or rsync -a
), but only touch the copied files, ie make all the copied files empty.我想模仿递归地复制目录结构(如在cp -r
或rsync -a
中),但只触摸复制的文件,即使所有复制的文件为空。
The specific use case is for a Snakemake pipeline;具体用例是Snakemake管道; Snakemake looks for existing files in order to decide whether to re-run a pipeline step, and I want to make it believe the steps have already been run while avoiding fully downloading all the files. Snakemake 查找现有文件以确定是否重新运行管道步骤,我想让它相信这些步骤已经运行,同时避免完全下载所有文件。
This is a little kludgy, but you could pipe the output of find
or rsync -nv
into a little bash loop with mkdir -p
and touch
:这有点笨拙,但是您可以使用 pipe 将find
或rsync -nv
的 output 放入一个小touch
循环中并使用mkdir -p
:
find /some/dir -type f | while read FILE; do
mkdir -p $(dirname $FILE)
touch $FILE
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.