remove all of a file type from a directory and its children

后端 未结 6 1705
南笙
南笙 2021-02-01 15:36

I was under impression that

rm -r *.xml

would remove all file from parent and child however:

*.xml: No such file or directory
         


        
6条回答
  •  借酒劲吻你
    2021-02-01 16:01

    I'm assuming you want to remove all *.xml files recursively (within current and all sub directories). To do that, use find:

    find . -name "*.xml" -exec rm {} \;
    

    On a side note, recursive deletion scares me. On my saner days, I tend to precede that step with:

    find . -name "*.xml" 
    

    (without the -exec bit) just to see what might get deleted before taking the leap. I advice you do the same. Your files will thank you.

提交回复
热议问题