LoginSignup
0
0

More than 5 years have passed since last update.

gzipコマンドの出力には入力ファイル名が含まれている(空データを圧縮させて調べてみた)

Last updated at Posted at 2018-09-19

こんにちは。
gzip コマンドで空データ(ゼロサイズ)を圧縮させ、その出力内容を調べてみました。出力(出力ファイル)の内部には入力ファイル名(もしくは入力先名)が含まれていました。出力のサイズを確認してもその分が格納されていることが分かります。

また less コマンドで確認することで、その入力先名が表示されますが、空データを圧縮させたものに対しては、その旨の警告らしき文字化け(?)が表示されました。macOS で動かしています。

$ echo -n "" | gzip > temp.txt.gz
$ ls -ld temp.txt.gz
-rw-r--r--  1 foo  staff  20  9 19 23:38 temp.txt.gz
$ echo "" | gzip > temp.txt.gz
$ ls -ld temp.txt.gz
-rw-r--r--  1 foo  staff  21  9 19 23:53 temp.txt.gz
$ touch temp.txt
$ gzip -c temp.txt > temp.txt.gz
$ ls -ld temp.txt*
-rw-r--r--  1 foo  staff   0  9 19 23:10 temp.txt
-rw-r--r--  1 foo  staff  29  9 19 23:16 temp.txt.gz
$ less temp.txt.gz
^_<8B>^H^H<F3>X<A2>[^@^Ctemp.txt^@^C^@^@^@^@^@^@^@^@^@
temp.txt.gz (END)
$
0
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
0
0