Is there any reason to escape a dot in a bash filename expansion?

I am working with a bash script that someone else wrote and I see the following line:


The files with which it’s working are all named like:


Is there any reason for the backslash escaping the dot since a dot isn’t treated specially in filename expansions? What are the implications of doing this vs without the backslash as such?:

Asked By: Dave Forgac


There is no difference. The dot . is not a special shell character that needs quoting, and the backslash will simply be removed during quote removal. This is true in most shells, not just bash.

Answered By: jw013

Not an answer to your question that has already been addressed by @jw013, but please note that while the and {} are superfluous here, there are a few things missing. Like the variables should be quoted, and -- to mark the end of options is missing.

Answered By: Stéphane Chazelas
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.