1
1

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 5 years have passed since last update.

ハードリンクが張られたファイルの圧縮解凍

Posted at

ハードリンクが張られたファイルをgzipやbzip2で圧縮または解凍する場合、オプション-fを添える必要がある。操作されなかったファイルはそのままで、リンク数が減る。

$ ls -l
total 8
drwxr-xr-x 2 glire glire 4096 May 26 15:18 bar
drwxr-xr-x 2 glire glire 4096 May 26 15:19 foo
$ ls -l foo/
total 66400
-r--r--r-- 1 glire glire 67993227 May 21  2017 baz
$ ls -l bar/
total 0
$ ln foo/baz bar/baz
$ ls -l bar/
total 66400
-r--r--r-- 2 glire glire 67993227 May 21  2017 baz
$ cd foo/
$ bzip2 baz
bzip2: Input file baz has 1 other link.
$ ls -l
total 66400
-r--r--r-- 2 glire glire 67993227 May 21  2017 baz
$ bzip2 -f baz
$ ls -l
total 8776
-r--r--r-- 1 glire glire 8986307 May 21  2017 baz.bz2
$ cd ../bar/
$ ls -l
total 66400
-r--r--r-- 1 glire glire 67993227 May 21  2017 baz
$ rm -f baz
$ ln ../foo/baz.bz2 baz.bz2
$ ls -l          
total 8776
-r--r--r-- 2 glire glire 8986307 May 21  2017 baz.bz2
$ bzip2 -d baz.bz2 
bzip2: Input file baz.bz2 has 1 other link.
$ bzip2 -df baz.bz2
$ ls -l
total 66400
-r--r--r-- 1 glire glire 67993227 May 21  2017 baz
$ ls -l ../foo/
total 8776
-r--r--r-- 1 glire glire 8986307 May 21  2017 baz.bz2
1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?