投げ銭

★当サイトへの投げ銭(PayPal)★

LINK


(無償、寄付歓迎) logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)

★LibreOfficeの導入事例★
詳細について

人気の投稿(1ヶ月間)

Ad

Ad

投げ銭

★当サイトへの投げ銭(PayPal)★

2021年4月7日水曜日

【Linux Raspbian】zip 圧縮するときの指定ディレクトリの除外、シンボリックリンク先の除外方法


Raspberry Pi (Raspbian)で、zipコマンドでディレクトリごとファイルを圧縮したい。
ただし、そのうち除外したいディレクトリがある。



# zip -y -r Archive.zip Target -x Target/SubDirectory/\*

(説明)
Archive.zip …生成される圧縮ファイルに付ける名前
Target …圧縮対象の親ディレクトリ名
-y …シンボリックリンクがあればリンク先のファイルまでは対象にはしない。
-r …圧縮対象の親ディレクトリ以下全てのディレクトリを対象にする。
-x Target/SubDirectory/\* …そのうちの除外するサブディレクトリ

Target/SubDirectory/\* は、親ディレクトリのTargetの直下にあるSubDirectoryディレクトリ内の全てのファイルやディレクトリを指定している。
\* はバックスラッシュが入っている。これはシェルによる * に対する展開処理をエスケープして、そのままの形でzipコマンドに渡すために必要なのだと思う。



<参考>
・Unix zip directory but excluded specific subdirectories (and everything within them)
< https://superuser.com/questions/312301/unix-zip-directory-but-excluded-specific-subdirectories-and-everything-within-t >

・How to zip directory excluding symbolic links and the files they point to?
< https://unix.stackexchange.com/questions/491004/how-to-zip-directory-excluding-symbolic-links-and-the-files-they-point-to >

投げ銭

★当サイトへの投げ銭(PayPal)★

Ad

Ad