I need to find all of the TIFFs in a directory, recursively, but ignore some artifacts (basically all hidden files) that also happen to end with ".tif". This command:
find . -type f -name '*.tif' ! -name '.*' works exactly how I want it on the command line, but inside a bash script it doesn't find anything. I've tried replacing ! with -and -not and--I think--just about every escaping permutation I can think of and/or recommended by the googleshpere, e.g. .\*, leaving out single quotes, etc. Obviously I'm missing something, any help is appreciated.
EDIT: here's the significant part of the script; the directory it's doing the find on is parameterized, but I've been debugging with it hard-coded; it makes no difference:
#!/bin/bash RECURSIVE=1 DIR=$1 #get the absolute path to $DIR DIR=$(cd $DIR; pwd) FIND_CMD="find $DIR -type f -name '*.tif' ! -name '.*'" if [ $RECURSIVE == 1 ]; then FIND_CMD="$FIND_CMD -maxdepth 1" fi for in_img in $($FIND_CMD | sort); do echo $in_img # for debugging #stuff done
.tifffiles?findcommand is looking for files matching '*.tif'..? Does it still not find anything?