Problem: suppose you have a bunch of jpeg files, with names such as
The command uses ImageMagick, it is for linux and it goes as
identify -format "%f %m\n" * | grep -v JPEG | awk '{ print $1 }' | xargs rmIdentify is an ImageMagick program that retrieves information about the image file, the -format option tells what to print (filename and format, as detected by the magic number).
The grep command takes all the lines that do *not* match "JPEG".
the awk takes the first word in the line (the filename).
The xargs concatenates the word to the command "rm" (REMOVE, again, pay attention!).