Title: [Bash] flash detector Author: Anonymous Pastebin link: http://pastebin.com/1GWQejEQ First Edit: Sunday 20th of July 2014 09:24:21 AM CDT Last Edit: Sunday 20th of July 2014 09:24:21 AM CDT #!/bin/bash file=$1 color1=$2 color2=$3 color3=$4 tolorance=10 amount=50 #echo "$file $color1 $color2 $color3" convert $file -colors 256 -depth 8 -format "%c" histogram:info: | # produces histogram         sort -g -r | #sort by amount         head -n $amount | #takes only $amount first colors         sed 's/^.*#[^(]*//g   s/[()]//g s/,/ /g' |  #changes the line to 'R G B' (each 0-255) while read x   # reads the individual lines do echo $x | sed 's/ /\n/g' | (  # puts R G B on separate lines and sends to subprocess         read R           read G         read B        # echo "$R $G $B"         RA=`expr $R - $color1`  # difference between tested color and 'line' color         GA=`expr $G - $color2`         BA=`expr $B - $color3`         if      [ $A -le $tolerance ] &&                   [ $A -le $tolerance ] &&                 [ $A -le $tolerance ] &&                 [ $A -ge "-$tolerance" ] &&                 [ $A -ge "-$tolerance" ] &&                 [ $A -ge "-$tolerance" ]                 then echo true  # checks wheter the difference is tolerable                 exit 0         fi         #echo false         exit 1         ) 2> /dev/null if [ $? -eq 0 ] # if the subprocess returned 0 (contains color), I return it too then exit 0 fi done exit 1