bash - excluding directory in "for file in $(find ...)"

view story

http://stackoverflow.com – 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}). 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!! Here's my 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 (HowTos)