find and remove files with space using find command on Linux

前端 未结 5 1167
温柔的废话
温柔的废话 2020-12-14 13:38

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

find . -iname \"*.db\"|while rea         


        
5条回答
  •  难免孤独
    2020-12-14 13:50

    First check if the first part of your command, that is:

    find . -iname "*.db"

    is returning anything.

    If it does then you can use xargs as follows to accomplish your task:

    find . -iname "*.db" | xargs rm -rfv

    UPDATE: From comments, this is unsafe, specially if there are spaces in directory/file names. You will need to use -print0 / xargs -0 to make it safe.

提交回复
热议问题