> I am missing how to create a bash-pattern that excludes a specific
pattern.
> 
> I.e. to ignore any file with '-IGN-' somewhere in the filename.
> 
> The best I've come up with so far has been to use shell to build
> a pattern, but I know it is limited in functionality.  I.e.:
> 
> ls !($(echo *+(-IGN-)*|tr " " "|"))
> 
> I tried the above in a dir that has 2 files w/the pattern, and
> 532 w/o, and it worked, but how much of that was 'luck'?
> 
> Is there a better bash-pattern that doesn't use tr and such?

A variation:
 
shopt -s nullglob
for f in ${1:-.}/*; do
  if [[ "${f}" != *-IGN-* ]];
    then printf -- '%s\n' "${f}"
  fi
done

Peggy Russell




Reply via email to