Recursive touch to fix syncing between computers [closed]

心已入冬 提交于 2019-12-03 06:42:53

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

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.

Edit:

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 {} \;

Edit by 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 /*.

So this is a solution to my immediate problem of touching all files, whether it works with dropbox will have to be seen.

In the root of the directory in question

find . -print -exec touch {} \;

(print is extraneous but it can be helpful for feedback)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!