在 Unix-like 的系統 (e.g. macOS, Linux), 我們很常用 rm
來刪除文檔。萬一誤刪檔案的話,要復原會有些麻煩。
所以很多時候,不如先放在垃圾桶 ( Bin
/ Trash
/ Recycle Bin
) 裡,方便有需要時可以尋回。
這次分享 macOS 一套軟件 trash
,可以在 Terminal 裡,將檔案方便地扔在 Bin
(~/.Trash
)裡。
可以用 Homebrew 安裝
homebrew install trash
簡單使用方法:
trash
取代 rm
刪除檔案時,可以在 Bin 裡找到。
trash -F
則是用 Finder 方式刪除。以這種方法刪除,好處在 Bin 裡可以選擇 Put Back
放回原本的路徑。
詳細使用方法:
usage: trash [-vlesyF] <file> [<file> ...]
Move files/folders to the trash.
Options to use with <file>:
-v Be verbose (show files as they are trashed, or if
used with the -l option, show additional information
about the trash contents)
-F Ask Finder to move the files to the trash, instead of
using the system API.
Stand-alone options (to use without <file>):
-l List items currently in the trash (add the -v option
to see additional information)
-e Empty the trash (asks for confirmation)
-s Securely empty the trash (asks for confirmation)
-y Skips the confirmation prompt for -e and -s.
CAUTION: Deletes permanently instantly.
Options supported by `rm` are silently accepted.
Version 0.9.2
Copyright (c) 2010–2018 Ali Rantakari, http://hasseg.org/trash