忽略以 0-3 位数字结尾的文件

mat*_*tth 6 git gitignore

这个问题以前肯定有人问过,但我找不到答案。
我想用来.gitignore忽略以下所有文件:

dsmodelext.c
dsmodelext1.c
dsmodelext2.c
dsmodelext23.c
dsmodelext107.c
Run Code Online (Sandbox Code Playgroud)

目前我在文件中放入了四行.gitignore

dsmodelext.c
dsmodelext[0-9].c
dsmodelext[0-9][0-9].c
dsmodelext[0-9][0-9][0-9].c
Run Code Online (Sandbox Code Playgroud)

有没有办法在一行中表达相同的内容?

dte*_*ech 5

Gitignore 采用fnmatch/glob 的语法,该语法在 man glob(7) 中指定

似乎没有办法指示需要匹配一定数量的字符,就像使用正则表达式一样dsmodelext[0-9]{0,3}.c

您可以决定宽容并定义dsmodelext*.c为被忽略。