在连续文件名中查找缺失的数字(高级ls& find) [英] Find missing numbers in continuous filenames (advanced ls & find)

查看:478
本文介绍了在连续文件名中查找缺失的数字(高级ls& find)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个脚本,可以随时间生成递增的文件夹名称(100,101,102,103,104等等)。这些文件夹在计算机之间同步,并且系统2上的任何给定文件夹都有创建失败的机会。



系统1总是同步的:
100 /
101 /
102 /
103 /
104 /
etc ...



有错误:
100 /
102 /
103 /
etc ...



101 /& 104 /在系统2)



如何生成系统2上所有丢失的文件夹的列表? / p>

PS
Rsync不是真正的选项,因为文件夹的实际数量是令人难以置信的高。

解决方案

ls 在每台机器上的一个文件,然后diff这两个文件。您还可以使用命令 comm 显示只在一个文件中的行,而不在其他文件中。


Let's say I have a script that generates incrementing folder names over time (100, 101, 102, 103, 104, etc...). These folders are synced between machines and there is a chance of creation failure for any given folder on system 2.

System 1 is always in sync: 100/ 101/ 102/ 103/ 104/ etc...

System 2 may have errors: 100/ 102/ 103/ etc...

(as you can see, 101/ & 104/ are missing on system 2)

How can I generate a list of all the missing folders on System 2?

P.S. Rsync is not really an option because the actual number of folders is incredibly high.

解决方案

You can pipe the contents of ls on each machine to a file, and then diff the two files. You can also use the command comm to show lines that are only in one file, and not in the other.

这篇关于在连续文件名中查找缺失的数字(高级ls& find)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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