rm -rf ~/a/b/c 时误删了文件怎么办?

2014-05-15 16:19:57 +08:00
 amoblin
在输入路径时如果一不留神按了回车。。。 :(

大家有木有因为这个命令误删文件(夹)的呢?

一般如何避免呢?

我能想到的一个方法:

cd /a/b; rm -rf c

不过感觉略嫌麻烦~
5467 次点击
所在节点    程序员
24 条回复
lizheming
2014-05-16 10:49:59 +08:00
@amoblin 他们说Github是保存一个月的,应该不会这么快吧...不过我之前用新浪微博登陆的,总是频繁要求登陆,后来我就怒了..自从用了SF自己的登陆后,登陆什么的再也不用烦恼了(´Д`)
wizardoz
2014-05-16 11:48:18 +08:00
先打路径,路径确认以后按C+a到行首打rm -fr。
不过我一般不会直接用-fr参数,都是删除的时候提示错误,才会加上这个参数。
gerorim
2014-05-18 19:55:21 +08:00
Install trash-cli

$ sudo apt-get install trash-cli

Put files in the trash with

$ trash-put file1 file2

alias rm='trash-put'
amoblin
2014-05-23 17:12:44 +08:00
@gerorim mac下如何使用apt-get安装trash-cli呢?不过受此启发,brew search trash发现了好东西:rmtrash ---- rmtrash is a small utility that will move the file to OS X's Trash rather than obliterating the file (as rm does).

貌似不错。很方便的解决了 :)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/112690

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX