title: Linux filename check if exist and delete
body: <p>I have some problem in Shell scripting.
  So I have to write a script that find every file in a directory with this string: "gom". So i found all of them. After I need to cut it off, and compare that the remaining filename is exist. If exist i need to remove the file that contains the string.</p>
  
  <p>Example: there are 5 files: algomb, gomba, alb, algomba, alba.</p>
  
  <p>I need to find the filenames with "gom". algomb, gomba, algomba.
  After it i need to cut the "gom". And a remaining filenames is exist I need to remove the file with "gom" string.
  So after the cutting "gom" there will be 5 files: alb, ba, alb, alba, alba
  So there are two files that is extist: alb, alba....I need to remove the following files: algomb, albomba.
  After it the will be 3 files: gomba, alb, alba.</p>
  
  <p>Sorry for my bad english.</p>
  
  <p>I can find, I can remove, but I cant compare the filenames. </p>
  
  <p>Here's my code: </p>
  
  <pre><code>#!/bin/bash 
  sz="gom"
  talal=`find . -type f -name "*$sz*" -exec basename {} \;`
  ossz=`find . -type f -exec basename {} \;`
  c=`echo ${talal%%:*}${talal##*:}`
  
  for c in ossz; do       
  if [ ! -d ]; then
      echo "This is a directory"  
  else    
  if [ -f ];
  then
      find .-type f -name "*$sz*" -exec basename {} \;  
  else    
      echo ${talal%%:*}${talal##*:} 
  
  fi  
  fi
  done
  </code></pre>
  
  <p>So this is works. This <code>echo ${talal%%:*}${talal##*:}</code> is give back the filename without "gom". But I cant compare these values with <code>find . -type f -exec basename {} \;</code> results.</p>
  
  <p>Sorry for my bad english.
  Can sombody help me?</p>
  
  <p>Best regards, Richard</p>