linux删除文件不需要确定,linux的rm命令 |
您所在的位置:网站首页 › linux删除文件内容不删除文件夹 › linux删除文件不需要确定,linux的rm命令 |
linux的rm命令-删除文件或目录 英文原意:remove 命令所在路径:/bin/rm 语法:rm -r 文件或目录,为目录时要加-r,且删除需要用户确认,如果不需要用户确认则 语法为:rm -r -f 功能:删除文件 例子:删除/test/testfile1文件 [root@localhost test]# rm /test/testfile1 rm: remove regular empty file `/test/testfile1'? y 最后面的?后面的y表示yes即确认删除,输入y后按回车键即删除成功 例子:删除一个多级目录,由于是目录,要加-r否则删除不成功 [root@localhost test]# rm /test/test1 rm: cannot remove `/test/test1': Is a directory 例子:删除一个多级目录,由于目录下有目录,则每一级删除的时候都需要用户确认 [root@localhost test]# rm -r /test/test1 rm: descend into directory `/test/test1'? y rm: descend into directory `/test/test1/test'? y rm: remove regular empty file `/test/test1/test/testfile1'? y rm: remove directory `/test/test1/test/test1'? y rm: remove directory `/test/test1/test'? y rm: remove regular empty file `/test/test1/testfile'? y rm: remove directory `/test/test1'? y [root@localhost test]# 例子:删除一个多级目录,且不需要用户确定是否删除,加-f达到效果,表示不需要用户确认 [root@localhost test]# rm -r -f /test/test2 -r -f也可以这样合并到一起写: [root@localhost test]# mkdir /test/test1 [root@localhost test]# mkdir /test/test1/test1 [root@localhost test]# rm -rf /test/test1 [root@localhost test]# |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |