7

When calling

bzip2 file.txt

I get this error message

bzip2: Input file file.txt has 1 other link

I'm using OSX, but I think this problem is not specific to OSX, so I'm asking here.

Matthias M
  • 12,906
  • 17
  • 87
  • 116

2 Answers2

14

I solved it using the force flag: -f

Don't know why.

aguadopd
  • 553
  • 8
  • 17
  • I don't know if bzip2 write to the same file handle it reads from. If it does, which it presumably does to make you use the force flag for linked files, it's probably a good idea to use `-fk` to keep the old file as it was. – Will S Feb 09 '22 at 11:31
  • It happened to me as well. It seems it's because Google Drive was also syncing this file at the same time. Check if this directory is synced by Dropbox or any other software, that could explain why it's used. – Guillaume Renoult Jan 11 '23 at 22:17
  • I wonder if this can happen also with files which were synced in the past but now they stopped to be synced. The link issue happened to me inside such folder which is not part of GDrive/OneDrive anymore. – tlask Feb 01 '23 at 22:14
  • This worked for me in a NTFS filesystem mounted on Linux – golimar Apr 22 '23 at 16:24
0

My solution was to copy the file:

cp file.txt tmp
rm file.txt
mv tmp file.txt
bzip2 file.txt

But perhaps someone could explain it anyway?

Matthias M
  • 12,906
  • 17
  • 87
  • 116
  • 1
    It happens because file.txt has a hard link to another file. There's a discussion about it here: http://jeremy.zawodny.com/blog/archives/010745.html – trh Sep 02 '15 at 14:04
  • Just discovered that this can happen when the file is no link at all also, at least in MacOs. `-f` flag helps anyway there. – JaakL Mar 26 '18 at 07:33