0

This question already has an answer here:

I have a folder that consists of other folders (whose names are unknown), .tar archives and JPEG images. How can I remove everything except .jpeg files?

marked as duplicate by Zanna, Arronical, Community Mar 15 '17 at 14:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

use below command :

ls -1 | grep -v "jpeg" | xargs -I {} rm -rf {}.

ls -1 show all content of your directory -1 will show each file in one line .

grep -v "jpeg" work in reverse mode means just only those file that's not end with "jpeg" .

and last command xargs accept each file name from previous command and pass it to rm command to delete those file.

Not the answer you're looking for? Browse other questions tagged or ask your own question.