What is the difference between "*.txt" and ".*" as wildcard patterns in bash globbing?
Correct! Well done.
Incorrect.
The correct answer is A) "*.txt" matches any filename ending in ".txt" (excluding hidden files by default), while ".*" matches any filename starting with a dot, which includes hidden files like ".bashrc" as well as the special entries "." and ".."
Correct Answer
"*.txt" matches any filename ending in ".txt" (excluding hidden files by default), while ".*" matches any filename starting with a dot, which includes hidden files like ".bashrc" as well as the special entries "." and ".."
Bash glob patterns don't match dotfiles with "*" unless explicitly using a pattern starting with "."; ".*" matches anything starting with a dot, including "." and ".." themselves, which is a common gotcha when using "rm .* " accidentally.