如何在linux中创建一个脚本以删除目录中的所有文件,期望仅保留5个文件
如何在Linux中创建一个脚本以从目录条件删除所有文件: - 如果在目录中仅保留5个文件,则不应从该目录中删除任何文件。
How to create a script in Linux to delete all files from the directory Condition:- If in the directory only 5 files are left then should not delete any files from that directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了解决该问题,请在for-loop之前的文件名更改设置“ IFS” shell变量的设置:
to fix the problem with spaces in filenames change setting of 'IFS' shell variable before the for-loop: