How to delete all files expect specific file type in the folder using command line [closed]

StackOverflow https://stackoverflow.com/questions/23114835

문제

I have lot of files in specific folder.

I want to delete all files expect *.html file type in that folder.

Is there any way to do this in command line? I am using Linux.

도움이 되었습니까?

해결책

I'll assume that you refer to linux command line, please update your question if not.

find ./folder/to/look/in -not -iname '*.html' -exec rm {} \; 

Here's an explanation of what this does

edit

If you have not too many files then you might want to make find execute one single rm command. You can do that with using + instead of ;

find ./folder/to/look/in -not -iname '*.html' -exec rm {} +

Here's an explanation of this one

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top