用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
# 附录A-练习14:删除文件 (rm) 这节练习中,你将学会如何使用`rm`命令删除一个文件。 ### 做到这些 ### Linux ~~~ $ cd temp $ ls uncool.txt iamcool.txt neat.txt something thefourthfile.txt $ rm uncool.txt $ ls iamcool.txt neat.txt something thefourthfile.txt $ rm iamcool.txt neat.txt thefourthfile.txt $ ls something $ cp -r something newplace $ $ rm something/awesome.txt $ rmdir something $ rm -rf newplace $ ls $ ~~~ ### Windows ~~~ > cd temp > ls Directory: C:\Users\zed\temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 12/22/2011 4:52 PM newplace d---- 12/22/2011 4:52 PM something -a--- 12/22/2011 4:49 PM 0 iamcool.txt -a--- 12/22/2011 4:49 PM 0 neat.txt -a--- 12/22/2011 4:49 PM 0 thefourthfile.txt -a--- 12/22/2011 4:49 PM 0 uncool.txt > rm uncool.txt > ls Directory: C:\Users\zed\temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 12/22/2011 4:52 PM newplace d---- 12/22/2011 4:52 PM something -a--- 12/22/2011 4:49 PM 0 iamcool.txt -a--- 12/22/2011 4:49 PM 0 neat.txt -a--- 12/22/2011 4:49 PM 0 thefourthfile.txt > rm iamcool.txt > rm neat.txt > rm thefourthfile.txt > ls Directory: C:\Users\zed\temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 12/22/2011 4:52 PM newplace d---- 12/22/2011 4:52 PM something > cp -r something newplace > rm something/awesome.txt > rmdir something > rm -r newplace > ls > ~~~ ### 你应该学到的 这里我们清理了之前练习中的所有文件。还记得我让你尝试使用`rmdir`删除一个不为空的目录吗?那个操作失败了因为你无法删除包含文件在内的目录。要做到这一点,你需要删除文件,或者递归删除所有的内容。这是你要在本节练习结尾要做的事情。 ### 更多练习 > - 清理从开始练习到现在所有`temp`目录下的文件。 > - 在你的笔记本上写下递归删除文件时一定要小心。