Search code examples
bashfileglob

Select all files with glob, except for specific file


I'm trying to match a glob that's all .exe's in a nested folder, but skip over UnityCrashHandler32.exe/UnityCrashHandler64.exe explicitly.

I've been playing around with some combination of !(UnityCrashHandler32\.exe|UnityCrashHandler64\.exe) but it's not lining up correctly! Can't quite see what I'm missing

Thanks so much, Ollie

Current Glob:

foo/{*/*,*}.exe

What I'd like it to do:

❌ foo/test.png
✅ foo/thing.exe
✅ foo/thing/thing.exe
❌ foo/UnityCrashHandler64.exe
❌ foo/UnityCrashHandler32.exe
❌ foo/thing/UnityCrashHandler64.exe
❌ foo/thing/UnityCrashHandler32.exe

https://www.digitalocean.com/community/tools/glob?comments=true&glob=foo%2F%7B%2A%2F%2A%2C%2A%7D.exe&matches=false&tests=foo%2Ftest.png&tests=foo%2Fthing.exe&tests=foo%2Fthing%2Fthing.exe&tests=foo%2FUnityCrashHandler64.exe&tests=foo%2FUnityCrashHandler32.exe&tests=foo%2Fthing%2FUnityCrashHandler64.exe&tests=foo%2Fthing%2FUnityCrashHandler32.exe


Solution

  • Like this maybe?

    foo/**/@(!(UnityCrashHandler[0-9][0-9])).exe
    

    Or

    foo/**/!(UnityCrashHandler[0-9][0-9]).exe
    

    With more pattern/glob to match, put the .exe inside the last )

    foo/**/@(!(UnityCrashHandler[0-9][0-9]).exe)
    

    Add a pipe | after the .exe and add your next pattern/glob.


    See