I want to ignore some folders generated with random numeric names even float numbers, but I do not know how to peek them to include in the .gitignore
file
2 Answers
How about something like:
* //Ignore everything
!*[!0-9.]* //Except things with some characters besides numbers (and period, for decimals) in them
!*.*.* //And except things with two periods, since these can't be numbers
Note that these are shell globs instead of regular expressions.

- 1,613
- 17
- 24
-
I think you mean `!*[^0-9.]*` – jthill Nov 15 '16 at 23:05
-
@jthill No, I think this is right. Shell globbing uses `!` instead of the `^` used in regexes. Both work on my system actually, but POSIX says that `!` negates character classes, while `^` is undefined. See [glob(7)](http://man7.org/linux/man-pages/man7/glob.7.html) – Chris Nov 16 '16 at 02:12
Ideally, if gitignore supported regular expression, it might have been possible to use a regex as detailed here.
However, from the official git documentation here :
Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".
Regular expression is not supported at the time of this writing (2016-11-15) and the expressions in gitignore are interepreted as shell glob patterns.
If the random folders being generated do not share a common parent directory and there is nothing else common in their names, then this does seem to be possible.
Is it possible to generate the folders with a common prefix or suffix so that that can be used in the .gitignore?

- 1
- 1

- 18,501
- 4
- 62
- 91
-
1Hi, thanks for your reply, its no posible generate the names with prefix o something, becasse, are not generated by me, the are the time results of a simulation procces, and are located in the same directory where I have the simulation configuration. I also try to use the `!` to fix the needed dirs and avoid all others but didn't work – efirvida Nov 15 '16 at 18:49
-
1Hmm, the only thing I can suggest is doing something like `find -type d -ctime -30s -maxdepth 1 -exec echo {} >> .gitignore \;` everytime the simulation process runs. This should add the names of the directories created in the last 30 seconds to gitignore. – Ashutosh Jindal Nov 15 '16 at 18:54