\HeaderA{unlink}{Delete Files and Directories}{unlink}
\keyword{file}{unlink}
\begin{Description}\relax
\code{unlink} deletes the file(s) or directories specified by \code{x}.
\end{Description}
\begin{Usage}
\begin{verbatim}unlink(x, recursive = FALSE)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a character vector with the names of the file(s) or
directories to be deleted.
Wildcards (normally \file{*} and \file{?}) are allowed.
\item[\code{recursive}] logical. Should directories be deleted
recursively?
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{recursive = FALSE} directories are not deleted,
not even empty ones.

On most platforms \sQuote{file} includes symbolic links, fifos and sockets.
Some earlier versions of \R{} would bot try to remove broken symbolic links.

Wildcard expansion is done by the internal code of
\code{\LinkA{Sys.glob}{Sys.glob}}. Wildcards never match a leading \file{.} in
the filename, and files \file{.} and \file{..} will never be
considered for deletion.
Wildcards will only be expanded if the system supports it.  Most
systems will support not only \file{*} and \file{?}) but character
classes such as \file{[a-z]} (see the \code{man} pages for
\code{glob}).  The metacharacters \code{* ? [} can occur in Unix
filenames, and this makes it difficult to use \code{unlink} to delete
such files (see  \code{\LinkA{file.remove}{file.remove}}), although escaping the
metacharacters by backslashes usually works.  If a
metacharacter matches nothing it is considered as a literal character.

\code{recursive = TRUE} is not supported on all platforms, and may be
ignored, with a warning.
\end{Details}
\begin{Value}
\code{0} for success, \code{1} for failure.
Not deleting a non-existent file is not a failure, nor is being unable
to delete a directory if \code{recursive = FALSE}.  However, missing
values in \code{x} result are regarded as failures.
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{file.remove}{file.remove}}.
\end{SeeAlso}

