[转]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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!