rm

rm(path::AbstractString; recursive=false)

Delete the file, link, or empty directory at the given path. If recursive=true is passed and the path is a directory, then all contents are removed recursively.

Examples

Here are some examples of how to use the rm function in Julia:

  1. Delete a file:

    julia> rm("file.txt")

    This example deletes the file named "file.txt" from the current working directory.

  2. Delete a directory:

    julia> rm("directory", recursive=true)

    This example deletes the directory named "directory" from the current working directory. The recursive=true argument ensures that all contents within the directory are removed recursively.

  3. Delete a symbolic link:

    julia> rm("symlink")

    This example deletes the symbolic link named "symlink" from the current working directory.

Common mistake example:

julia> rm("nonexistent_file.txt")
ERROR: SystemError: unlink: no such file or directory (ENOENT)

In this example, the error occurs because the specified file does not exist. It's important to ensure that the file, link, or directory you want to delete actually exists before using the rm function.

See Also

abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: