被删除的文件位于: .local/share/Trash, 恢复的话,需要自己去目录手动拷贝回原位置,如何得到原位置,查看 .local/share/Trash/info 目录下的信息文件。
For Ubuntu 18.04 and newer, use gio
. For older versions, use gvfs-ls
and gvfs-trash
.
To read the trash:
gio list trash:// gvfs-ls trash://
To send files or directories to the trash (支持 * 通配符):
gio trash [FILE or FILES or DIR or DIRS]
gvfs-trash [FILE or FILES or DIR or DIRS]
To empty it:
gio trash --empty
gvfs-trash --empty
可以将 rm 重新定义,定义如下:
(该代码无法删除 ./ 和 ../ 、../../ 、 ../../../ 等目录,也无法删除 ../file、 ../../file 等目录或文件,若要删除这些,请用 gio trash,不过要小心,因为 gio trash 真的可以将目录移动到 trash里,不管你任何时候操作,别大意将 home 目录移动到trash里了,不过也没关系,trash并不会删除文件。)
(它也会将所有参数全部忽略,即会将 -r -rf -file 都忽略,因此删除的文件若第一个字符本来就是 -, 则必须用 gio trash 来移入回收站。)
function rm --description 'vote each account of eosnameswaps' if test (count $argv) -lt 1 return 0 end # for a in $argv[1..-1] # if test $a = "." # echo "no" # return 1 # end # end for i in (seq (count $argv)) if test $argv[$i] = "." echo "do not delete ./" return 1 end if test $argv[$i] = "./" echo "do not delete ./" return 1 end switch $argv[$i] case "*..*" echo "do not delete ../ or ../../ or ../file etc." return 1 case "-*" set argv[$i] "" end end # if test (count $argv) -lt 2 -o "$argv[1]" = "--help" # echo "" # end echo "move it/them to trash." gio trash $argv end