title: Loop thru a filename list and iterate thru a variable/array removing all strings from filenames with bash
body: <p>I have a list of strings that I have in a variable and would like to remove those strings from a list of filenames. I'm pulling that string from a file that I can add to and modify over time. Some of the strings in the variable may include part of the item needed to be removed while the other may be another line in the list. Thats why I need to loop thru the entire variable list. </p>
  
  <p>I'm familiar using a while loop to loop thru a list but not sure how I can loop thru each line to remove all strings from that filename. </p>
  
  <p>Here's an example:</p>
  
  <pre><code>getstringstoremove=$(cat /text/from/some/file.txt)
  echo "$getstringstoremove"
  
  # Or the above can be an array
  getstringstoremove=$(cat /text/from/some/file.txt)
  declare -a arr=($getstringstoremove)
  </code></pre>
  
  <p>the above 2 should return the following lines</p>
  
  <pre><code>-SOMe.fil
  (Ena)M-3_1
  .So[Me].filEna)M-3_2
  SOMe.fil(Ena)M-3_3
  </code></pre>
  
  <p>Here's the loop I was running to grab all filenames from a directory and remove anything other than the filenames</p>
  
  <pre><code>ls -l "/files/in/a/folder/" | awk -v N=9 '{sep=""; for (i=N; i&lt;=NF; i++) {printf("%s%s",sep,$i); sep=OFS}; printf("\n")}' | while read line; do 
  echo "$line"
  </code></pre>
  
  <p>returns the following result after each loop</p>
  
  <pre><code># 1st loop 
  ilikecoffee1-SOMe.fil(Ena)M-3_1.jpg
  # iterate thru $getstringstoremove to remove all strings from the above file.
  # 2nd loop
  ilikecoffee2.So[Me].filEna)M-3_2.jpg
  # iterate thru $getstringstoremove again
  # 3rd loop
  ilikecoffee3SOMe.fil(Ena)M-3_3.jpg
  # iterate thru $getstringstoremove and again
  done
  </code></pre>
  
  <p>the final desired output would be the following</p>
  
  <pre><code>ilikecoffee1.jpg
  ilikecoffee2.jpg
  ilikecoffee3.jpg
  </code></pre>
  
  <p>I'm running this in bash on Mac.
  I hope this makes sense as I'm stuck and can use some help.</p>
  
  <p>If someone has a better way of doing this by all means it doesn't have to be the way I have it listed above. </p>