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

后端 未结 6 1703
南笙
南笙 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:18

    The man page of rm says:

     -r, -R, --recursive
              remove directories and their contents recursively
    

    This means the flag -r is expecting a directory. But *.xml is not a directory.

    If you want to remove the all .xml files from current directory recursively below is the command:

    find . -name "*.xml" -type f|xargs rm -f
    

提交回复
热议问题