rm:删除文件


在rm命令后加上要删除的文件名

[root@hostwiki.info ~]# rm test.txt

有的系统上输入完命令后可能会再次确认,需要输入Y来删除或者输入N取消。
可以加上-f选项直接删除,不用询问。

[root@hostwiki.info ~]# rm test.txt
rm: remove regular file `test.txt'? N(输入N,取消删除)
[root@hostwiki.info ~]# rm -f test.txt (使用-f选项直接删除)

如果删除的是目录,将会出错。

[root@hostwiki.info ~]# rm test
rm: cannot remove `test': Is a directory

如果要删除目录,必须要加上-r选项,这将删除目录里包含的所有子目录和文件。

[root@hostwiki.info ~]# rm -rf test
最后更改: in 2010/12/21 11:50