Shell – How to assign the cat output of a bash script to a variable in another script

catshell-scriptvariable

I have a bash script that produces a cat output when it takes an argument. I also have another bash script that executes the first bash script with an an argument that I want to produce cat outputs with. How do I store those cat outputs produced by the first bash script in variables?

Best Answer

var=$( cat foo.txt )

would store the output of the cat in variable var.

var=$( ./myscript )

would store the output of myscript in the same variable.

Related Question