Here are some caveats to watch out for when using wildcards. Since
bash treats wildcard-related characters (?,
[, ], *) specially, you need to take
special care when typing in an argument to a command that contains these
characters. For example, if you want to create a file that contains the string
[fo]*, the following command may not do what you want:
$ echo [fo]* > /tmp/mynewfile.txt
If the pattern [fo]* matches any files in the current working
directory, then you'll find the names of those files inside /tmp/mynewfile.txt
rather than a literal [fo]* like you were expecting. The
solution? Well, one approach is to surround your characters with
single quotes, which tell bash to perform absolutely no wildcard expansion on
them:
$ echo '[fo]*' > /tmp/mynewfile.txt