递归触摸修复计算机之间同步 [英] Recursive touch to fix syncing between computers

查看:88
本文介绍了递归触摸修复计算机之间同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在命令行的方式去触摸一个目录(和子目录)的所有文件,由于我的错误我的一个同步回购已经变得有点不合拍对我的发展机器。

I'm looking for a way from the command-line to touch every file in a directory (and subdirectories) due to a mistake of mine a synced repo of mine has gotten a bit out of step on my development machines.

我现在已经经历一些不愉快的巫术设法得到它回到一个干净的状态在一台机器上,我做下同步之前,我想要的一切,时间在本机上明智的优先级。

I've now through some unpleasant voodoo managed to get it back into a clean state on one machine, before I do the next sync, I want to prioritise everything time wise on this machine.

有没有一种简单的方法去触摸的所有文件?

Is there an easy way to touch all the files?

还是我做的更好的目录手动同步?

Or am I better doing a manual sync of the directory?

(我使用dropbox来同步供参考)

(I'm using dropbox for syncing for reference)

推荐答案

您可以使用找到的xargs 沿触摸每个文件在当前或指定目录或如下:

You could use find along with xargs to touch every file in the current or specified directory or below:

find . -print0 | xargs -0 touch

当前目录。对于一个指定的目录:

for the current directory. For a specified directory:

find /path/to/dir -print0 | xargs -0 touch

-print0 选项找到 -0 选项的xargs 使命令强大的通过使分隔符空到文件带有空格的名称。

The -print0 option to find along with the -0 option to xargs make the command robust to file names with spaces by making the delimeter a NULL.

编辑:

杰里米ĴStarchar在评论中说,上面是唯一合适的,如果你的找到的xargs 是一GNU工具链的一部分。如果你是全无GNU工具的系统上,你可以使用:

As Jeremy J Starchar says in a comment, the above is only suitable if your find and xargs are a part of the GNU toolchain. If you are on a system withour GNU tools you could use:

find . -exec touch {} \;

通过编辑 dcgregorya

不必做这对一个非常大的数据集,我发现这个命令是(大)更快。

Having to do this against a very large data set I've found this command to be (much) faster.

find ./ -type d -print0 | xargs -I{} -0 bash -c "touch {}/*"

限制找到找到文件夹然后执行触摸反对文件夹/*.

Limits find to finding folders then executes touch against folder /*.

这篇关于递归触摸修复计算机之间同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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