1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

zipしたのになぜか中身が空になってしまう

Last updated at Posted at 2023-09-20

結論

-rをつけましょう。

書式

# 書式
$ zip -r <圧縮後のzipファイル名> <圧縮するディレクトリのパス>

例1:/home/sigma/workを圧縮

$ zip -r sample.zip /home/sigma/work/

例2:カレントディレクトリ以下を全て圧縮

$ zip -r sample.zip *

解説

rオプションは、<圧縮するディレクトリのパス>で指定したディレクトリに含まれるディレクトリやファイルをまとめて圧縮するためのオプション

つまり、rオプションがなければディレクトリの中身は圧縮されないことになってしまう。

実質、zipコマンドを使うときはrオプションは必須。

感想

圧縮にはzipコマンドが使えることや引数の順番は覚えていたが、rオプションについては忘れていたので、何度zipしても空になってしまい焦った。

参考

  • 三宅英明・大角祐介『新しいLinuxの教科書[初版]』(SBクリエィティブ株式会社、2015年)
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?