Zip -rを使用して読み取り権限を持たないファイルを除外/無視しようとしています。

Zip -rを使用して読み取り権限を持たないファイルを除外/無視しようとしています。

書き込み専用ファイルを含むフォルダがありますが、圧縮時にそのファイルを除外したいと思います。

これらの書き込み専用ファイルに関する警告やエラーを見たくありません。

最良の方法を教えてください。

例:

sh:~/t12$ ls -l
total 0
--w--w--w- 1 som  som 0 Dec  5 05:59 a
-rw-rw-r-- 1 som  som 0 Dec  5 05:59 b
-rw-rw-r-- 1 som  som 0 Dec  5 05:59 c

sh:~/t12$ zip -r zipFileName /home/som/t12/*
  adding: home/som/t12/a
zip warning: Permission denied
    zip warning: could not open for reading: home/som/t12/a
  adding: home/som/t12/b (stored 0%)
  adding: home/som/t12/c (stored 0%)

zip warning: Not all files were readable
  files/entries read:  2 (0 bytes)  skipped:  1 (0 bytes)

ベストアンサー1

私は次のことを試してみます:

find . -readable -type f -exec zip -q zipFileName {} +

注文する:

find . -readable -type f

読み取り権限を持つすべてのファイルを返します.

第二部

-exec zip -q zipFileName {} +

zip見つかったファイル名を指定するコマンドを実行します。

おすすめ記事