I want to store the contents of a file in a bash shell variable. This works fine:
$ cat hello
Hello, world!
$ F=hello
$ Q=$(cat $F)
$ echo $Q
Hello, world!
However, if the file contains an asterisk, the asterisk is replaced by a list of all files in the current directory.
How can I quote the filename to protect the asterisk? Or otherwise load the file into the shell variable?
I am aware of this question, but it doesn't work for files that contain an asterisk.