Dom
Dom

Reputation: 1722

How to ignore file extensions with one additional character?

I've recently been curious on how to ignore certain extensions, but with exactly one extra character. One example of where this is relevant is in vim if the .swp already exists another extension is used, like .swo, .swn, etc. So for this pattern I'd be interested in *.sp plus exactly one character.

I've thought about using *.sp* to match this pattern however, I feel like there could be edge cases where this collects something unintended so I would prefer a more focused solution.

So is there a way in a gitignore file to specific any extra character to satisfy the patter above?

Upvotes: 1

Views: 517

Answers (2)

B. Assem
B. Assem

Reputation: 1078

Based on this link: https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files You can use ? to mean one character, so you can do: *.sp? and to be more specific, if you have a list of possible value for this one caractere then you can use: *.sp[abd] this will ignore .spa, .spb, .spd

Upvotes: 2

kkonrad
kkonrad

Reputation: 1262

If this one character is always present then use *.sp?. ? stands for exactly one character and it also works in Linux shell.

Upvotes: 2

Related Questions