Reputation: 553
I'm trying to write a find command that excludes directories that are numbers dash number, but allow other directories.
Sample directories
./135888897-135954433/
./135888897-135954434/
./135888897-135954435/
./BLAG-DEF-JOB1/
./TOM-DEPLOYDEV-JOB1/
./FRANK-RELEASE-JOB1/
./STEVE-RELEASE-JOB1/
Here's part of my find command. I can't seem to get it to skip the number directories.
find . -type f ! -regex '\./[0-9]+\-[0-9]+/*'
Any help would be great. Thanks!
Upvotes: 2
Views: 37
Reputation: 348
You should use .*
instead of *
.
When useing regex a *
means 'match the preceding token 0 or more times'
This will result in the following command:
find . -type f ! -regex '\./[0-9]+\-[0-9]+/.*'
Update: I also thought you forgot to escape the /
in your command, but after doing a little bit of research it seems escaping /
is not necessary when using the find
command.
Upvotes: 1