Unlink (Unix)


In Unix-like operating systems, unlink is a system call and a command line utility to delete files. The program directly interfaces the system call, which removes the file name and directories like rm and rmdir. If the file name was the last hard link to the file, the file itself is deleted as soon as no program has it open.
It also appears in the PHP, Node.js, R, Perl and Python standard libraries in the form of the unlink built-in function. Like the Unix utility, it is also used to delete files.

Example

To delete a file named foo, one could type:

% unlink foo

In PHP, one could use the following function to do the same:

unlink;

The Perl syntax is identical to the PHP syntax, save for the parentheses:

unlink "foo";

In Node.js it is almost the same as the others:

fs.unlink;

In R :

unlink
  1. Comment: using the inside argument 'recursive = TRUE', directories can be deleted

Similarly in Python:

os.unlink