Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Shell: remove all HTML files in tree while leaving directory structure

Tags:

linux

rm

I'm trying to remove all .html files from the directory generated and from all subfolders there but it needs to leave all other files and directories alone.

I tried going through folder by folder and running rm *.html but this takes a long time as there are 20+ subfolders which also have subfolders. I tried looking the man pages for rm but nothing obvious jumped out. I'm sure there's a way to do this in one shot but I don't know how. Any ideas?

like image 835
Joe Schmuck Avatar asked Jan 22 '14 07:01

Joe Schmuck


People also ask

How delete all files in subdirectories Linux?

To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r .


1 Answers

I think this may work:

cd generated

find . -type f -iname "*.html" -delete

like image 118
sagarchalise Avatar answered Oct 05 '22 06:10

sagarchalise