Unfortunately, I do not think that a solution with a cat will work. It can work on Linux, but I use FreeBSD, and I tried to use cat to import tempfiles, and it failed all the time.
The problem with cat (at least with FreeBSD) is that it forces the shell to interpret its "output" as a literal command, and also disables certain characters, which also causes problems.
My possible solution was to convert the mentioned tempfiles into holders for variables and then import them using the source command. It works, but I don't like it; mainly because I have to do some ugly cutting with the specified to prefix the data with the name of the variable and enclose it in quotation marks.
So, in the data file you will have: -
variable=foobar
Then in the script, I would do what created my output for the variable, and then, to get it in the script, would use: -
source datafile
at what point could I use the variable.
However, although this does not look like a stack, it works to store data. I do not like using single variables in shell scripts if I can avoid them; mainly because again it means resorting to the ugly lookup hacking, and can be annoying for debugging.
source share