代码之家  ›  专栏  ›  技术社区  ›  Mr. B.

Linux(zip):如何找到所有不可读的文件?

  •  5
  • Mr. B.  · 技术社区  · 7 年前

    我只是试着 文件夹及其内容:

    zip -r ./mytarget.zip ./mysource
    

    最后我得到了 警告 :

    zip warning: Not all files were readable
    files/entries read:  141595 (4.2G bytes)  skipped:  57 (1.8M bytes)
    

    跳过了哪些文件

    我怎样才能找到 所有不可读的文件? sudo 该服务器上的权限。

    2 回复  |  直到 7 年前
        1
  •  8
  •   Picaud Vincent    7 年前

    您可以使用

    find . ! -readable
    

    递归扫描不可读的文件或目录。这个命令考虑了权限,但也考虑了断开的链接。

        2
  •  4
  •   Hub 20xx Mat    7 年前

    find . ! -readable 没有帮助。

    我通过将zip命令的所有输出记录到一个文件来解决这个问题:

     zip -r my-archive.zip /path/to/dir/ &>> zip-log
    

    然后在其中搜索 warning word,它不仅作为摘要出现在命令输出的末尾,而且还出现在每个引起问题的文件之后(在我的示例中为2):

      adding: home/myuser/.cagefs/tmp/mysql.sock
        zip warning: could not open for reading: home/myuser/.cagefs/tmp/mysql.sock
      adding: home/myuser/.cagefs/tmp/lshttpd/ (stored 0%)
      adding: home/myuser/.cagefs/tmp/.s.PGSQL.5432
        zip warning: could not open for reading: home/myuser/.cagefs/tmp/.s.PGSQL.5432