在* nix中清空目录的最安全的方法是什么? [英] What is the safest way to empty a directory in *nix?

查看:151
本文介绍了在* nix中清空目录的最安全的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我害怕有一天,我要在我目前使用的命令中放置一个空格或错过一些内容:

I'm scared that one day, I'm going to put a space or miss out something in the command I currently use:

rm -rf ./*

有更安全的方式清空当前目录的内容?

Is there a safer way of emptying the current directory's contents?

推荐答案

最安全的方式是坐在你的手上,然后按Enter键。

The safest way is to sit on your hands before pressing Enter.

除此之外,你可以创建一个这样的别名(对于Bash)

That aside, you could create an alias like this one (for Bash)


alias rm="pwd;read;rm"

这将显示您的目录,等待输入新闻,然后删除您用正确的标志指定的内容。您可以按^ C而不是Enter取消。

That will show you your directory, wait for an enter press and then remove what you specified with the proper flags. You can cancel by pressing ^C instead of Enter.

这篇关于在* nix中清空目录的最安全的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆