Skip to main content
added 2 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
$ echo 'hello' >name
 
 
$ ln name othername
 
 
$ ls -l
total 4
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 name
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 othername
 
 
$ cat othername
hello
 
 
$ rm name
 
 
$ ls -l
total 2
-rw-r--r--  1 kk  wheel  6 Jun 25 09:45 othername
 
 
$ cat othername
hello

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed.

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its names).

See also: Forcibly create directory hard link(s)?

$ echo 'hello' >name
 
$ ln name othername
 
$ ls -l
total 4
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 name
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 othername
 
$ cat othername
hello
 
$ rm name
 
$ ls -l
total 2
-rw-r--r--  1 kk  wheel  6 Jun 25 09:45 othername
 
$ cat othername
hello

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed.

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its names).

See also: Forcibly create directory hard link(s)?

$ echo 'hello' >name
 
$ ln name othername
 
$ ls -l
total 4
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 name
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 othername
 
$ cat othername
hello
 
$ rm name
 
$ ls -l
total 2
-rw-r--r--  1 kk  wheel  6 Jun 25 09:45 othername
 
$ cat othername
hello

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed.

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its names).

See also: Forcibly create directory hard link(s)?

deleted 172 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
$ touchecho name'hello' >name

$ ln name othername 

$ ls -l
total 04
-rw-r--r--  2 kk  wheel  06 SepJun 1025 09:2945 name
-rw-r--r--  2 kk  wheel  06 SepJun 1025 09:2945 othername 

$ rmcat othername
hello

$ rm name

$ ls -l
total 02
-rw-r--r--  1 kk  wheel  06 SepJun 1025 09:2945 nameothername

$ cat othername
hello

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed:.

$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm -rf name
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 othername

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contentscontents (under all its names).

See also: Forcibly create directory hard link(s)?

$ touch name
$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm othername
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 name

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed:

$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm -rf name
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 othername

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its names).

See also: Forcibly create directory hard link(s)?

$ echo 'hello' >name

$ ln name othername 

$ ls -l
total 4
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 name
-rw-r--r--  2 kk  wheel  6 Jun 25 09:45 othername 

$ cat othername
hello

$ rm name

$ ls -l
total 2
-rw-r--r--  1 kk  wheel  6 Jun 25 09:45 othername

$ cat othername
hello

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed.

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its names).

See also: Forcibly create directory hard link(s)?

deleted 1 character in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
$ touch name
$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm othername
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 name

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed:

$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm -rf name
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 othername

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its'its names).

See also: Forcibly create directory hard link(s)?

$ touch name
$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm othername
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 name

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed:

$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm -rf name
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 othername

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its' names).

See also: Forcibly create directory hard link(s)?

$ touch name
$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm othername
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 name

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter, nor does it matter which name is removed:

$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm -rf name
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 othername

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.


It appears, from comments, that you are actually using an application that creates a hard link for a directory. This is possible on macOS HFS+ filesystems under certain conditions. It is generally really fiddly to work with hard linked directories, and their use is largely limited to things like Apple's own TimeMachine software.

Related Stackoverflow question: What is the Unix command to create a hardlink to a directory in OS X?

It is pointed out in amongst the answers to that question, that a hard linked directory needs to be deleted using unlink rather than rm -r since rm -r would delete the directory's contents (under all its names).

See also: Forcibly create directory hard link(s)?

added 22 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading
[Edit removed during grace period]
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading
added 564 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading
added 564 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading
added 302 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading