在Linux上使用find命令查找和删除具有空间的文件 [英] find and remove files with space using find command on Linux

查看:324
本文介绍了在Linux上使用find命令查找和删除具有空间的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ubuntu中使用 find 命令删除Windows分区中的所有thumbs.db文件:

I'm trying to remove all thumbs.db files in a Windows partition using find command in Ubuntu:

find . -iname "*.db"|while read junk;do rm -rfv $junk;done

但是它对我不起作用,什么也没发生!我想我发现了问题,目录名称中的空格!

But it's not working for me and nothing happens! I think I found the problem, the white spaces in directory names!

我曾经使用过这种技巧来删除以前版本的Ubuntu上的垃圾文件,但现在无法删除最新版本的Ubuntu.

I did this trick to remove my junk files before on previous version of Ubuntu but now on latest version of Ubuntu I can't.

我的命令中是否有任何错误?

Is there any bug in my command?

推荐答案

我会这样做:

find . -iname 'thumbs.db' -exec rm -rfv {} +

这样,即使您的目录名称中包含空格,它仍然可以工作.

This way, it still works even if your directories contain whitespace in their names.

这篇关于在Linux上使用find命令查找和删除具有空间的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆