rm

Deletes files specified as args.

If trash is enabled, moves the deleted file to the .Trash directory (given by getTrashRoot).

Returns 0 on success and -1 on error.

The usage is as follows:

$ hadoop fs -rm [-f] [-r |-R] [-skipTrash] [-safely] URI [URI ...]
Arguments

-f

Doesn’t display a diagnostic message or modify the exit status to reflect an error if the file doesn’t exist

-R

Deletes the directory and any content under it recursively

-r

Equivalent to the -R argument

-skipTrash

Bypasses the trash function, if enabled, and deletes the specified file(s) immediately. This can be useful when it is necessary to delete files from an over-quota directory

-safely

Requires safety confirmation before deleting directory with total number of files greater than hadoop.shell.delete.limit.num.files (in core-site.xml, default: 100). It can be used with -skipTrash to prevent accidental deletion of large directories. A delay is expected when walking over large directory recursively to count the number of files to be deleted before the confirmation

Example:

$ hadoop fs -rm hdfs://nn.example.com/file /user/hadoop/emptydir
Found a mistake? Seleсt text and press Ctrl+Enter to report it