linux通用命令 无意输入rm -rf /* 成为程序员最奔溃的瞬间?
·
系列文章目录
前言
linux 系统下,程序员删除文件或目录,使用最多的就是 rm -rf ,但是当输入 rm -rf ./* 误操作为 rm -rf /* ,尤其是在开发环境,那就是事故了。
因此尽可能少用 rm,而用回收站 trash-cli 包的命令 trash-put 进行替代。
一、trash-cli是什么?
trash-cli 可以将文件或目录删除到回收站。
二、使用步骤
trash-put help 说明:
$ trash-put --help
Usage: trash-put [OPTION]... FILE...
Put files in trash
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-d, --directory ignored (for GNU rm compatibility)
-f, --force ignored (for GNU rm compatibility)
-i, --interactive ignored (for GNU rm compatibility)
-r, -R, --recursive ignored (for GNU rm compatibility)
-v, --verbose explain what is being done
To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
trash -- -foo
trash ./-foo
Report bugs to https://github.com/andreafrancia/trash-cli/issues
以下是 trash-cli 的使用场景:
$ sudo apt install trash-cli # 安装 trash-cli 包
$ trash-put xxx yyy # 删除文件或目录 xxx yyy
$ trash-restore # 恢复回收站的文件
$ trash-empty # 清空回收站文件
$ trash-list # 列出回收站文件
$ trash-rm # 直接删除,而不放到回收站
总结
本文介绍了在使用 rm 最崩溃的瞬间,最后使用了 trash-cli 作为该命令的替代。
更多推荐
所有评论(0)