Linux (zip): how to find all files that are not readable?
Asked Answered
C

3

9

I just tried to zip folder and it's content by this command:

zip -r ./mytarget.zip ./mysource

At the end I got the warning:

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

I'd like to know which files were skipped.

How can I find all the files that were not readable? I don't have sudo rights on that server.

Thanks in advance!

Cork answered 13/9, 2017 at 4:46 Comment(2)
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask.Jedediah
@Jedediah It's part of a script, so kind of in the middle of Stackoverflow and Super User.Cork
F
14

you can use

find . ! -readable

to recursively scan for unreadable files or directories. This command takes into account permissions, but also broken links.

Fionnula answered 13/9, 2017 at 5:2 Comment(1)
Thanks, but it didn't show any files. The files were probably blocked by something else, because the zipping was successfully a few tries later.Cork
O
8

I experienced the same as you, and find . ! -readable didn't help.

I solved it by logging all output from the zip command to a file:

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

and then searching in it for the warning word, which did not only occured at the end of the command's output, as a summary, but also just after each of the files causing trouble (2 in my case):

  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
Osculum answered 13/2, 2018 at 11:37 Comment(0)
A
0

I fix this by updating the zip package and clear all the cache, here is the step :

  • delete the previous zip (which failed)
  • sudo apt-get update
  • sudo apt-get upgrade
  • clear & purge all the cache from web dashboard and cloudflare
  • reboot the server
  • try zip these files
Anew answered 12/1, 2023 at 3:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.