uunnlliinnkk() -- System Call (libc)

Remove a file
#iinncclluuddee <uunniissttdd.hh>
iinntt uunnlliinnkk(_n_a_m_e) cchhaarr *_n_a_m_e;

uunnlliinnkk()  removes the  directory entry  for the given  file _n_a_m_e,  which in
effect erases _n_a_m_e  from the disk.  _n_a_m_e cannot be  opened once it has been
uunnlliinnkk()'d. If  _n_a_m_e is the last  link, uunnlliinnkk() frees the  i-node and data
blocks.  Deallocation is  delayed if the file is open.   Other links to the
file remain intact.

_E_x_a_m_p_l_e
This example removes the files named on the command line.

#include <unistd.h>
main(argc, argv)
int argc; char *argv[];
{
    int i;

    for (i = 1; i < argc; i++) {
        if (unlink(argv[i]) == -1) {
            printf("Cannot unlink \"%s\"\n", argv[i]);
            exit(EXIT_FAILURE);
        }
    }
    exit(EXIT_SUCCESS);
}

_S_e_e _A_l_s_o
lliibbcc, lliinnkk(), llnn, rreemmoovvee(), rrmm, rrmmddiirr, uunniissttdd.hh
POSIX Standard, section 5.5.1

_D_i_a_g_n_o_s_t_i_c_s
uunnlliinnkk()  returns zero  when successful.   It returns -1  if _f_i_l_e  does not
exist,  if the  user  does not  have  write and  search  permission in  the
directory containing _f_i_l_e, or if _f_i_l_e is a directory and the invoker is not
the superuser.
