title: bash - excluding directory in "for file in $(find ...)"
body: <p>I have to do a script, which copy all the *.txt files from home directory to the newly created directory specified in the first argument of this script (${1}).</p>
  
  <p>If the backup directory already exists, I want to skip it. I was trying the -prune excluding in find, but it doesn't work for me. Finally I have made if statement in the loop, which also doesn't work, and I don't know why...Thank's for help!!</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#!/bin/bash
  
  mkdir ${1}
  
  for file in $(find ~/ -name *.txt)
  
  do
  
      if [ ! -f ~/${1}/$file ]
      then
          cp -i -v $file -t ~/${1}
      fi
  
  done
  </code></pre>