I was under impression that
rm -r *.xml
would remove all file from parent and child however:
*.xml: No such file or directory
I was under impression that
rm -r *.xml
would remove all file from parent and child however:
*.xml: No such file or directory
I'm assuming you want to remove all
*.xml
files recursively (within current and all sub directories). To do that, usefind
:On a side note, recursive deletion scares me. On my saner days, I tend to precede that step with:
(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.ZSH recursive globbing to the rescue!
Invoke zsh:
zsh
Be sure you're in the dir you intend to be in:
cd wherever
List first:
ls **/*.xml
Remove:
rm **/*.xml
I'll resist the strong temptation to bash on
bash
, and just point to the relevant zsh docs on the topic here.An easy way to do is
This will remove all .xml files from current directory.
Reading this answer on finding empty directories unix, I just learned about the -delete action:
Source: man find
That means, you can also delete all xml-files recursively like this:
more beautiful way, although this one is less supported in unix systems:
this will remove xml files from all sub-directories of you current directory.
The man page of rm says:
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: