LinuxCommandLibrary

trash-cli

TLDR

Move file to trash

$ trash-put [file]
copy
List trashed files
$ trash-list
copy
Restore file
$ trash-restore
copy
Empty trash
$ trash-empty
copy
Remove files older than days
$ trash-empty [30]
copy
Remove specific trashed file
$ trash-rm [pattern]
copy

SYNOPSIS

trash-put files
trash-list
trash-restore
trash-empty [days]
trash-rm pattern

DESCRIPTION

trash-cli provides a command-line interface to the FreeDesktop.org trash. It moves files to trash instead of permanently deleting them.
Files are moved to ~/.local/share/Trash following the freedesktop.org specification. Desktop environments can see and restore these files.
Restoration is interactive. trash-restore lists trashed files with numbers, and you select which to restore.
Empty trash permanently deletes trashed files. Age-based emptying removes only old files, keeping recent deletions recoverable.
The tools work with filesystem trash on external drives. Each mounted filesystem has its own trash directory.
Aliasing rm to trash-put provides safer default behavior while maintaining familiar syntax.

PARAMETERS

-d, --directory

Allow trashing directories (trash-put).
-f, --force
Ignore nonexistent files.
-v, --verbose
Verbose mode.
--version
Show version.
--help
Show help.

COMMANDS

trash-put FILES

Move files to trash.
trash-list
List trashed files.
trash-restore
Interactively restore files.
trash-empty [N]
Empty trash (or files older than N days).
trash-rm PATTERN
Remove matching trashed files.

CAVEATS

Trash uses disk space until emptied. Trashing large files fills disk. Doesn't work on filesystems without trash support. Root trash is separate.

HISTORY

trash-cli was created by Andrea Francia to provide command-line access to the standard Linux trash. It follows the FreeDesktop.org Trash specification for interoperability.

SEE ALSO

rm(1), gio(1), gvfs-trash(1)

Copied to clipboard