{"id":134501,"date":"2019-01-24T09:40:54","date_gmt":"2019-01-24T01:40:54","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=134501"},"modified":"2019-01-23T13:01:26","modified_gmt":"2019-01-23T05:01:26","slug":"rm-chance-back","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/rm-chance-back.html","title":{"rendered":"rm \u7ed9\u4f60\u4e00\u4e2a\u53cd\u6094\u7684\u673a\u4f1a"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nLinux \u4e0b rm \u547d\u4ee4\u662f\u8868\u793a\u5220\u9664\u4e00\u4e2a\u6587\u4ef6\uff0c\u800cLinux\u662f\u6ca1\u6709\u56de\u6536\u7ad9\u673a\u5236\uff0c\u6240\u4ee5\u6587\u4ef6\u4e00\u65e6\u5220\u9664\u7684\u8bdd\uff0c\u5c31\u5f7b\u5e95\u4ece\u78c1\u76d8\u4e0a\u5220\u9664\u4e86\u3002\u800c\u5f88\u591a\u4eba\u559c\u6b22\u52a0\u4e0a -f \u9009\u9879\uff0c\u662f\u4ee3\u8868\u5f3a\u5236\u7684\u610f\u601d\uff0c\u66f4\u66b4\u529b\u7684\u662f\u5220\u9664\u6587\u4ef6\u5939\u7684\u65f6\u5019\u4f7f\u7528 rm -rf \u547d\u4ee4\uff0c\u8fd9\u6837\u4e00\u6765\uff0c\u6587\u4ef6\u5939\u672c\u8eab\uff0c\u4ee5\u53ca\u6587\u4ef6\u5939\u4e0b\u7684\u5b50\u5b50\u5b59\u5b59\uff0c\u90fd\u4e00\u4e86\u767e\u4e86\u4e86\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u800c\u4e07\u4e00\u5982\u679c\u4f60\u6267\u884c\u4e86 rm -rf \/* \u547d\u4ee4\uff0c\u90a3\u65e0\u7591\u6548\u679c\u4e0e\u4e0b\u9762\u7b49\u540c\uff1a
\n\"\"<\/p>\n

\u7531\u4e8e\u6ca1\u6709\u56de\u6536\u7ad9\u673a\u5236\uff0c\u5f88\u591a\u4eba\u5403\u8fc7\u8fd9\u4e2a\u4e8f\uff0c\u826f\u8bb8\u4e5f\u662f\uff0c\u66fe\u7ecf\u8f9b\u82e6\u5199\u7684\u51e0\u4e2a\u6708\u7684\u4ee3\u7801\uff0c\u4e00\u4e2a rm \u547d\u4ee4\u5168\u90e8\u5316\u4e3a\u4e4c\u6709\uff0c\u641e\u5f97\u6bcf\u6b21\u6267\u884c rm \u547d\u4ee4\u7684\u65f6\u5019\uff0c\u624b\u90fd\u662f\u98a4\u6296\u7684\u2026\u2026<\/p>\n

\u65e2\u7136Linux\u6ca1\u6709\u56de\u6536\u7ad9\uff0c\u90a3\u6211\u4eec\u80fd\u5426\u81ea\u5df1\u5b9e\u73b0\u4e00\u4e2a\uff1f\u7b54\u6848\u5f53\u7136\u662f\u80af\u5b9a\u7684\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u5c31\u81ea\u5df1\u52a8\u624b\u505a\u4e00\u4e2a\u56de\u6536\u7ad9\uff0c\u7ed9\u81ea\u5df1\u4e00\u4e2a\u540e\u6094\u7684\u673a\u4f1a\u3002<\/p>\n

\u65e2\u7136\u7f6a\u9b41\u7978\u9996\u662f rm \u547d\u4ee4\uff0c\u90a3\u6211\u4eec\u5c31\u5bf9\u8fd9\u4e2a\u547d\u4ee4\u8fdb\u884c\u6539\u9020\u3002\u5728Linux\u4e0b\u5bf9\u547d\u4ee4\u8fdb\u884c\u91cd\u5b9a\u4e49\u662f\u4f7f\u7528 alias \u547d\u4ee4\uff0c\u4fee\u6539\u7684\u662f .bashrc \u6587\u4ef6\uff0c\u5373\uff1a<\/p>\n

\r\nvim ~\/.bashrc\r\n\u5728\u6587\u4ef6\u5c3e\u90e8\uff0c\u6211\u4eec\u6dfb\u52a0\u4ee5\u4e0b\u51e0\u53e5\u4ee3\u7801\uff1a\r\n\r\nmkdir -p ~\/.trash\r\nalias rm=trash\r\nalias r=trash\r\nalias rl='ls ~\/.trash\/'\r\nalias ur=undelfile\r\n\r\nundelfile()\r\n{\r\n    mv -i ~\/.trash\/$@ .\/\r\n}\r\n\r\ntrash()\r\n{\r\n    mv -i $@ ~\/.trash\/\r\n}\r\n\r\ncleartrash()\r\n{\r\n    read -p \"clear sure?[n]\" confirm\r\n    [ $confirm == 'y' ] || [ $confirm == 'Y' ] && \/bin\/rm -rf ~\/.trash\/*\r\n}\r\n<\/pre>\n

\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u662f\u5728\u5bb6\u76ee\u5f55\u4e0b\u5efa\u7acb\u4e00\u4e2a .trash \u7684\u9690\u85cf\u6587\u4ef6\u5939\uff0c\u4f5c\u4e3a\u56de\u6536\u7ad9\u3002\u7136\u540e\uff0c\u6211\u4eec\u5bf9 rm \u547d\u4ee4\u8fdb\u884c\u91cd\u5b9a\u4e49\u3002\u5f53\u6211\u4eec\u6267\u884c rm \u6216\u8005 r \u7684\u65f6\u5019\uff0c\u5c06\u6267\u884c trash \u51fd\u6570\u3002\u800c\u5728 trash \u51fd\u6570\u91cc\uff0c\u53ea\u505a\u4e00\u4ef6\u4e8b\uff1a<\/p>\n

\r\nmv -i $@ ~\/.trash\/\r\n<\/pre>\n

\u5c31\u662f\u5c06 rm \u4e4b\u540e\u6240\u6709\u7684\u6587\u4ef6\u79fb\u52a8\u5230 .trash \u76ee\u5f55\u4e0b\uff08\u5373\u6a21\u62df\u4e22\u8fdb\u56de\u6536\u7ad9\uff09\u3002-i \u9009\u9879\u8868\u793a\u5982\u679c .trash \u76ee\u5f55\u6709\u540c\u540d\u6587\u4ef6\u7684\u8bdd\uff0c\u5c06\u63d0\u793a\u662f\u5426\u8986\u76d6\u3002<\/p>\n

\u6211\u4eec\u5c06 rl \u5b9a\u4e49\u4e3a ls ~\/.trash\/ \uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 rl \u6765\u67e5\u770b .trash \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\uff0c\u5373\u88ab\u300c\u5220\u9664\u300d\u7684\u6587\u4ef6\u3002<\/p>\n

\u5982\u679c\u8981\u8fd8\u539f\u6587\u4ef6\uff0c\u53ef\u4ee5\u6267\u884c ur \uff0c\u800c ur \u5c06\u6267\u884c undelfile \u51fd\u6570\u3002\u5728 undelfile \u91cc\uff0c\u53c8\u5c06 ur \u4e4b\u540e\u7684\u6587\u4ef6\u4ece .trash \u76ee\u5f55\u79fb\u56de\u5230\u539f\u76ee\u5f55\uff0c\u4ece\u800c\u5b9e\u73b0\u6587\u4ef6\u5220\u9664\u8fd8\u539f\u3002<\/p>\n

\u5f53\u8fc7\u4e86\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u56de\u6536\u7ad9\u91cc\u6587\u4ef6\u592a\u591a\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 cleartrash \u547d\u4ee4\u6e05\u7a7a\u56de\u6536\u7ad9\u3002\u5b83\u5c06\u6267\u884c\u540c\u540d\u51fd\u6570\uff0c\u8c03\u7528 \/bin\/rm \u547d\u4ee4\u5c06 .trash \u76ee\u5f55\u6e05\u7a7a\u3002<\/p>\n

.bashrc \u6587\u4ef6\u4fee\u6539\u5b8c\u6bd5\u4e4b\u540e\uff0c\u6211\u4eec\u8981\u8ba9\u5b83\u751f\u6548\uff1a<\/p>\n

\r\nsource ~\/.bashrc\r\n<\/pre>\n

\u6211\u4eec\u6765\u5b9e\u9645\u4f53\u4f1a\u4e00\u4e0b\uff1a<\/p>\n

\r\n\u5220\u9664\u6587\u4ef6\r\nalvin@alvin-pc:~\/test$ touch file1 file2 file3\r\nalvin@alvin-pc:~\/test$ ls\r\nfile1  file2  file3\r\nalvin@alvin-pc:~\/test$ rm file1 file2 \r\nalvin@alvin-pc:~\/test$ r file3\r\n\u67e5\u770b\u56de\u6536\u7ad9\u6587\u4ef6\r\nalvin@alvin-pc:~\/test$ rl\r\nfile1  file2  file3\r\n\u8fd8\u539f\u88ab\u5220\u9664\u7684\u6587\u4ef6\r\nalvin@alvin-pc:~\/test$ rl\r\nfile1  file2  file3\r\nalvin@alvin-pc:~\/test$ ur file1\r\nalvin@alvin-pc:~\/test$ ur file2\r\nalvin@alvin-pc:~\/test$ ur file3\r\nalvin@alvin-pc:~\/test$ ls\r\nfile1  file2  file3\r\nalvin@alvin-pc:~\/test$ rl\r\nalvin@alvin-pc:~\/test$ \r\n\u6e05\u7a7a\u56de\u6536\u7ad9\r\nalvin@alvin-pc:~\/test$ rm file1 file2 file3\r\nalvin@alvin-pc:~\/test$ rl\r\nfile1  file2  file3\r\nalvin@alvin-pc:~\/test$ cleartrash\r\nclear sure?[n]y\r\nalvin@alvin-pc:~\/test$ rl\r\nalvin@alvin-pc:~\/test$\r\n<\/pre>\n

\u901a\u8fc7\u4ee5\u4e0a\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u6211\u4eec\u867d\u7136\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u56de\u6536\u7ad9\u7684\u529f\u80fd\uff0c\u4f46\u5b9e\u9645\u7684\u5de5\u4f5c\u4e2d\uff0c\u6211\u4eec\u8fd8\u662f\u8981\u517b\u6210\u5b9a\u65f6\u5907\u4efd\u7684\u4e60\u60ef\uff0c\u8fd9\u6837\u5373\u4f7f\u6709\u8bef\u64cd\u4f5c\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5c06\u635f\u5931\u964d\u5230\u6700\u4f4e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u800c\u4e07\u4e00\u5982\u679c\u4f60\u6267\u884c\u4e86 rm -rf \/* \u547d\u4ee4\uff0c\u90a3\u65e0\u7591\u6548\u679c\u4e0e\u4e0b\u9762\u7b49\u540c\uff1a \u7531\u4e8e\u6ca1\u6709\u56de\u6536\u7ad9\u673a\u5236\uff0c\u5f88\u591a\u4eba\u5403\u8fc7\u8fd9\u4e2a\u4e8f\uff0c\u826f […]<\/p>\n","protected":false},"author":63,"featured_media":134502,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-134501","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/134501","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=134501"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/134501\/revisions"}],"predecessor-version":[{"id":134769,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/134501\/revisions\/134769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/134502"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=134501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=134501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=134501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}