■Windowsで解凍しなくてはならない場合のパスワード付きZIPの作り方(debian) $sudo apt-get install -y zip unzip ■圧縮、確認、解凍 $ zip -P password sample.zip sample updating: sample (deflated 43%) $ zipinfo sample.zip Archive: sample.zip Zip file size: 369 bytes, number of entries: 1 -rw-r--r-- 3.0 unx 313 TX defN 14-Aug-11 21:42 sample 1 file, 313 bytes uncompressed, 179 bytes compressed: 42.8% $ unzip sample.zip Archive: sample.zip [sample.zip] sample password: replace sample? [y]es, [n]o, [A]ll, [N]one, [r]ename: y inflating: sample ■中身の確認 $ cat sample for n in `seq 1 21`;do \ for m in `seq 1 21`;do \ if [ $n -eq $m ];then \ echo -n "XXXX"; \ else \ echo "$m $n" | awk '{if((22-$1)==$2){printf "XXXX"}else{printf "%04d",$1*$2}}';fi | \ sed s/"[0-9][0-9][0-9][0-9]"/" "/g | sed s/"XXXX"/" X"/g; \ done;echo; \ done $ /bin/bash sample X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X ■複数ファイルの場合、デフォルトが追加なので、 以下のように出来る。 $ /bin/bash sample > sample.log $ du sample* 4 sample 4 sample.log $ for list in sample*;do zip -P password sample.zip "$list";done adding: sample (deflated 43%) adding: sample.log (deflated 90%) $ zipinfo sample.zip Archive: sample.zip Zip file size: 638 bytes, number of entries: 2 -rw-r--r-- 3.0 unx 313 TX defN 14-Aug-11 21:42 sample -rw-r--r-- 3.0 unx 903 TX defN 14-Aug-11 21:44 sample.log 2 files, 1216 bytes uncompressed, 272 bytes compressed: 77.6% ■シェルの複数選択も出来る。 $ zip -P password sample.zip sample* updating: sample (deflated 43%) updating: sample.log (deflated 90%) ■分けても良い。 $ for list in sample*;do zip -P password "${list}.zip" "${list}";done updating: sample (deflated 43%) adding: sample.log (deflated 90%) adding: sample.zip (stored 0%) $ du *.zip 4 sample.log.zip 4 sample.zip 4 sample.zip.zip ■ディレクトリ $ mkdir sample_dir && mv sample*.zip sample_dir/ $ zip -r -P password sample.zip sample_dir adding: sample_dir/ (stored 0%) adding: sample_dir/sample.zip.zip (stored 0%) adding: sample_dir/sample.zip (stored 0%) adding: sample_dir/sample.log.zip (stored 0%) $ zipinfo sample.zip Archive: sample.zip Zip file size: 2547 bytes, number of entries: 4 drwxr-xr-x 3.0 unx 0 bx stor 14-Aug-11 21:50 sample_dir/ -rw-r--r-- 3.0 unx 836 BX stor 14-Aug-11 21:48 sample_dir/sample.zip.zip -rw-r--r-- 3.0 unx 638 BX stor 14-Aug-11 21:48 sample_dir/sample.zip -rw-r--r-- 3.0 unx 291 BX stor 14-Aug-11 21:48 sample_dir/sample.log.zip 4 files, 1765 bytes uncompressed, 1765 bytes compressed: 0.0% ■パイプ 「Windowsって何それ?おいしいの?」という場合のみ。 $ sudo dd if=/dev/sda bs=512 count=1 | zip -P mbr mbr.zip - updating: -1+0 レコード入力 1+0 レコード出力 512 バイト (512 B) コピーされました、 0.000103309 秒、 5.0 MB/秒 (deflated 27%) $ zipinfo mbr.zip Archive: mbr.zip Zip file size: 605 bytes, number of entries: 1 prw------- 3.0 unx 512 Bl defN 14-Aug-11 22:01 - 1 file, 512 bytes uncompressed, 373 bytes compressed: 27.1% $ unzip -c mbr.zip | hexdump -C 00000000 41 72 63 68 69 76 65 3a 20 20 6d 62 72 2e 7a 69 |Archive: mbr.zi| [mbr.zip] - password: 00000010 70 0a 20 20 69 6e 66 6c 61 74 69 6e 67 3a 20 2d |p. inflating: -| 00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000030 20 20 20 20 20 20 20 0a eb 63 90 00 00 00 00 00 | ..c......| 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000090 00 00 00 80 c2 93 00 00 00 00 00 00 ff fa 90 90 |................| 000000a0 f6 c2 80 74 05 f6 c2 70 74 02 b2 80 ea 79 7c 00 |...t...pt....y|.| 000000b0 00 31 c0 8e d8 8e d0 bc 00 20 fb a0 64 7c 3c ff |.1....... ..d|<.| 000000c0 74 02 88 c2 52 be 80 7d e8 17 01 be 05 7c b4 41 |t...R..}.....|.A| 000000d0 bb aa 55 cd 13 5a 52 72 3d 81 fb 55 aa 75 37 83 |..U..ZRr=..U.u7.| 000000e0 e1 01 74 32 31 c0 89 44 04 40 88 44 ff 89 44 02 |..t21..D.@.D..D.| 000000f0 c7 04 10 00 66 8b 1e 5c 7c 66 89 5c 08 66 8b 1e |....f..\|f.\.f..| 00000100 60 7c 66 89 5c 0c c7 44 06 00 70 b4 42 cd 13 72 |`|f.\..D..p.B..r| 00000110 05 bb 00 70 eb 76 b4 08 cd 13 73 0d f6 c2 80 0f |...p.v....s.....| 00000120 84 d8 00 be 8b 7d e9 82 00 66 0f b6 c6 88 64 ff |.....}...f....d.| 00000130 40 66 89 44 04 0f b6 d1 c1 e2 02 88 e8 88 f4 40 |@f.D...........@| 00000140 89 44 08 0f b6 c2 c0 e8 02 66 89 04 66 a1 60 7c |.D.......f..f.`|| 00000150 66 09 c0 75 4e 66 a1 5c 7c 66 31 d2 66 f7 34 88 |f..uNf.\|f1.f.4.| 00000160 d1 31 d2 66 f7 74 04 3b 44 08 7d 37 fe c1 88 c5 |.1.f.t.;D.}7....| 00000170 30 c0 c1 e8 02 08 c1 88 d0 5a 88 c6 bb 00 70 8e |0........Z....p.| 00000180 c3 31 db b8 01 02 cd 13 72 1e 8c c3 60 1e b9 00 |.1......r...`...| 00000190 01 8e db 31 f6 bf 00 80 8e c6 fc f3 a5 1f 61 ff |...1..........a.| 000001a0 26 5a 7c be 86 7d eb 03 be 95 7d e8 34 00 be 9a |&Z|..}....}.4...| 000001b0 7d e8 2e 00 cd 18 eb fe 47 52 55 42 20 00 47 65 |}.......GRUB .Ge| 000001c0 6f 6d 00 48 61 72 64 20 44 69 73 6b 00 52 65 61 |om.Hard Disk.Rea| 000001d0 64 00 20 45 72 72 6f 72 0d 0a 00 bb 01 00 b4 0e |d. Error........| 000001e0 cd 10 ac 3c 00 75 f4 c3 00 00 00 00 00 00 00 00 |...<.u..........| 000001f0 ec f0 ff bb 00 00 00 00 01 00 ee fe ff ff 01 00 |................| 00000200 00 00 2f 60 38 3a 00 00 00 00 00 00 00 00 00 00 |../`8:..........| 00000210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000230 00 00 00 00 00 00 55 aa 0a |......U..| 00000239