Skip to Content
gnux

rmx

Remove (unlink) files and directories.

Mirrors GNU rm. Run it as rmx, or as gnux rmx.

Synopsis

rmx [OPTION]... [FILE]...

GNU reference

Description

rmx removes each FILE. By default it does not remove directories; use -r to remove a directory and everything under it, or -d to remove an empty directory. Prompting is controlled by -i (before every removal), -I (once before a bulk or recursive removal) and --interactive; -f disables all prompts and ignores missing files. rmx refuses to remove '.' and '..' and, by default, refuses to recurse on the filesystem root. Independent arguments are removed concurrently whenever no prompt or ordered output is involved. On a terminal, gnux's terminal view colors the -v report: the verb (removed, created, renamed), each quoted name and the arrows, in the theme --theme or GNUX_THEME names; the words are GNU's, and piped or redirected output is never colored (--pretty=never or GNUX_PRETTY=never turns it off).

Permissions

Removing an entry needs write and search permission on the directory that contains it, not on the entry itself. On a terminal, a write-protected file triggers a confirmation prompt unless -f is given.

Use cases

  • Everyday file cleanup.
  • Unattended deletion in CI or scripts with -f.
  • Cautious, per-file review with -i, or one confirmation before a large delete with -I.
  • Auditing a recursive delete with -rv.
  • Clearing build output (build/, dist/, node_modules/) before a fresh build.
  • Pruning directories that should already be empty with -d, without risking contents.
  • Removing temporary files a script created, even if some were never written (-f).
  • Deleting a tree without crossing into mounted volumes (--one-file-system).
  • Removing files whose names start with '-' by ending options with --.

Flags

  -d, --dir                             remove empty directories
  -f, --force                           ignore nonexistent files and arguments, never prompt
      --help                            display this help and exit
      --interactive string[="always"]   prompt according to WHEN: never, once, or always
      --no-preserve-root                do not treat '/' specially
      --one-file-system                 when removing recursively, skip directories on a different file system
      --preserve-root                   do not remove '/' (default) (default true)
      --pretty WHEN[="always"]          the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
  -i, --prompt-each                     prompt before every removal
  -I, --prompt-once                     prompt once before removing more than three files, or when removing recursively
  -r, --recursive                       remove directories and their contents recursively
      --theme NAME                      color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
  -v, --verbose                         explain what is being done
      --version                         output version information and exit

Examples

Remove a few files

rmx notes.txt draft.md

Recursively remove a directory, reporting each deletion

rmx -rv build/

Unattended cleanup: no prompts, ignore missing paths

rmx -rf /tmp/cache

Remove an empty directory only

rmx -d generated/

Ask before each removal

rmx -i *.bak

Ask once before a recursive delete

rmx -I -r old-project/

Choose the prompt policy explicitly

rmx --interactive=once *.log

Answer every prompt with yes from a pipeline

yesx | rmx -i a.tmp b.tmp

Remove a file whose name starts with a dash

rmx -- -draft.txt

Remove a tree but skip file systems mounted beneath it

rmx -r --one-file-system scratch/

Disable the root failsafe for a deliberate recursive delete

rmx -rf --no-preserve-root /mnt/scratch

Clean up and rebuild only if the removal succeeded

rmx -rf dist/ && mkdirx dist

Detect a failed removal in a script

rmx missing.txt || echox "rmx exited with $?"

Count how many entries a recursive delete removed

rmx -rv cache/ | wcx -l

Remove temporary files with the gnux shell

gnux shell -c 'rmx -fv *.tmp && echox done'

Options

Each option has a page of its own, with its usage and examples.

Exit status

StatusMeaning
0success: every operand was processed
1failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake

Help in the terminal

rmx --help                # options, first examples, exit status
gnux help rmx             # this page: the full manual
gnux help rmx --OPTION    # one option in depth, with its examples

See also

On this page