[转]Linux 基本操作(RM 删除)
Posted 秤心
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[转]Linux 基本操作(RM 删除)相关的知识,希望对你有一定的参考价值。
来自:http://billie66.github.io/TLCL/book/chap05.html
Be Careful With rm!
小心 rm!
Unix-like operating systems such as Linux do not have an undelete command. Once you delete something with rm, it’s gone. Linux assumes you’re smart and you know what you’re doing.
类 Unix 的操作系统,比如说 Linux,没有复原命令。一旦你用 rm 删除了一些东西, 它就消失了。Linux 假定你很聪明,你知道你在做什么。
Be particularly careful with wildcards. Consider this classic example. Let’s say you want to delete just the html files in a directory. To do this, you type:
尤其要小心通配符。思考一下这个经典的例子。假如说,你只想删除一个目录中的 HTML 文件。输入:
rm *.html
which is correct, but if you accidentally place a space between the “*” and the “.html” like so:
这是正确的,如果你不小心在 “*” 和 “.html” 之间多输入了一个空格,就像这样:
rm * .html
the rm command will delete all the files in the directory and then complain that there is no file called “.html”.
这个 rm 命令会删除目录中的所有文件,还会抱怨没有文件叫做 “.html”。
Here is a useful tip. Whenever you use wildcards with rm (besides carefully checking your typing!), test the wildcard first with ls. This will let you see the files that will be deleted. Then press the up arrow key to recall the command and replace the ls with rm.
小贴士。 当你使用带有通配符的rm命令时(除了仔细检查输入的内容外), 先用 ls 命令来测试通配符。这会让你看到将要被删除的文件是什么。然后按下上箭头按键,重新调用 刚刚执行的命令,用 rm 替换 ls。
以上是关于[转]Linux 基本操作(RM 删除)的主要内容,如果未能解决你的问题,请参考以下文章