Well
Assuming the bullet has enough velocity, yes, it can shoot until it bumps into something
However, the gunpowder needs to ignite to send off the bullet, requiring oxygen.
I probably overcomplicated a simple meme but here ya go :p
Thanks, I couldn't really understand. I thought there wouldn't be any oxygen to light it. But isn't there bullets with air inside them. They can shoot underwater so they should in space too right?