Recently, I am busy coding the bash script to feed my needs. However, during the coding time, I found the usage of double quotes is contradicted with each other at some times. For example, I try to find some files that matched the regex, such as ls "*.log". I habitually wrap the *.log with double quotes but get the error cannot access '*.txt': No such file or directory.
After that, I found the reason from a tutorial that it is useless to put the * in double-quotes when you want the * acts as a wildcard. Therefore, ls *.log is the correct usage.
However, when I use the grep command with regex, all three of them ("",'',non-quote) do not change the original meaning of my regex, such as grep "^s.txt". At this time, double-quotes make the regex active.
Is there exist some design conflicts between the commands? And could you please give me some tricks to quickly grasp the correct usage of quotes for usual commands?