Using bash, how to find files in a directory structure except for *.xml files? I\'m just trying to use
find . -regex ....
regexe:
You can also do it with or-ring as follows:
find . -type f -name "*.xml" -o -type f -print
with bash:
shopt -s extglob globstar nullglob
for f in **/*!(.xml); do
[[ -d $f ]] && continue
# do stuff with $f
done
Sloppier than the find
solutions above, and it does more work than it needs to, but you could do
find . | grep -v '\.xml$'
Also, is this a tree of source code? Maybe you have all your source code and some XML in a tree, but you want to only get the source code? If you were using ack, you could do:
ack -f --noxml
find . ! -name "*.xml" -type f
Try something like this for a regex solution:
find . -regextype posix-extended -not -regex '^.*\.xml$'
find . -not -name '*.xml'
Should do the trick.