Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
964 views
in Technique[技术] by (71.8m points)

shell - find and remove files with space using find command on Linux

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!

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'd do it this way:

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...