I have a loop comparing strings that it still does not kick it out if it matches. the set up is many different types of file extensions, only want to delete the ones I do not want keeping the ones I do want. easier route is by not knowing what is in the dir is to tell it what I want to keep then have it just delete the rest. it does not work it still deletes everything within the dir and sub dirs. This is how it is basically set up within the script with two loops within it now, find $working_dir -type f -name *.* | while [ $xf  -lt $numberToConvert ] ; do read FILENAME;echo before loopecho path1 is -> ${path1}echo Ext1 is -> $ext1#Checks each movie file to see if it is just a not neededsample    of the move to regain file space by deleting it   j=$FILENAME   xpath=${j%/*}    xbase=${j##*/}   xfext=${xbase##*.}   xpref=${xbase%.*}   path1=${xpath}   pref1=${xpref}   ext1=${xfext}for file in ${path1} ; do echo in for loop ext1 is -> $ext1   if [[ $ext1 != 'flac' || $ext1 != 'mp3'  ]]; then    echo in loop if statement ext is -> $ext1    echo Removing $FILENAME    removeme=$FILENAME    rm -v $removeme  fidoneif [[ ${ext1} == 'mp3' || ${ext1} == 'flac' ]] ; then # other code to do stuff to mp3 and flac files here within the outter loop fi #outter loop done statement done output of term is:before looppath1 is -> /media/data/temp1/Joe Jackson - The Ultimate Collection/CD2Ext1 is -> mp3in for loop ext1 is -> mp3in loop if statement ext is -> mp3Removing /media/data/temp1/Joe Jackson - The Ultimate Collection/CD2/07 Joe Jackson - Be My Number Two.mp3removed /media/data/temp1/Joe Jackson - The Ultimate Collection/CD2/07 Joe Jackson - Be My Number Two.mp3Extension of before into first if statement foobarTotal Files Left are 41the second if statement works it was only been letting in mp3 and flac, and has been working I just decided to try this to get rid of the rest of files that are not mp3 or flac within the directories now, and, I've tried all of the variations that I can think of with the quote marks '$var' $var and brackets ${var} around the var name and the [ ] and [[ ]] on the if statement. nothing seems to work. it just deletes everything no matter what.  I already know that == is equal to and != is not equal to in string comparison. http://tldp.org/LDP/abs/html/comparison-ops.html
if statement not working properly
shell script;string
The boolean logic of your first test is wrong:if [[ $ext1 != 'flac' || $ext1 != 'mp3'  ]]Every file matches that: if your ext is mp3 then $ext1 != 'flac' is true.You want one ofif [[ $ext1 != 'flac' && $ext1 != 'mp3'  ]]if ! [[ $ext1 == 'flac' || $ext1 == 'mp3'  ]]if [[ ! ($ext1 == 'flac' || $ext1 == 'mp3')  ]]