Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k 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 OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...