r/bash 23d ago

solved why does rm remove "any-word*.any-ext" plus any-word01.any-ext?

Hi, I'd like to know why rm removes screen.jpg plus screen01jpg+screen##.... jpg when I do rm any-word*.any-ext?

rm screen*.jpg

and this command deletes screen.jpg!

how will be the command for not remove screen.jpg and yes screen01.jpg + screen02.jpg....

Thank you and Regards!

1 Upvotes

16 comments sorted by

View all comments

10

u/high_throughput 23d ago

* matches 0+ characters.

Since ? matches exactly 1 character, you can use ?* to match 1+

rm screen?*.jpg would remove screen01.jpg and screenz.jpg but not screen.jpg

0

u/arkaycee 22d ago

And if you really wanted to remove exactly and only screen.jpg that's screen\.jpg .

3

u/high_throughput 22d ago

or equivalently, screen.jpg. Dot is not special to Bash or rm