Writing from a notebook to a textfile, using the MAC OS X terminal?

Given the following code in a Mathematica notebook named test.nb:

var = 3*Exp[t] - 4*t;
Export["test.txt", var];

I can make the files test.m and test.wls corresponding to test.nb.

However, I would like to obtain the output in test.txt by using the MAC terminal.

How can this be done?

I’ve tried the following:

wolframscript -file test.nb

and

/Applications/Mathematica12.app/Contents/MacOS/MathKernel -noprompt -run "<<test.m"

but neither approach yields output.

Thanks in advance for any help.

In test.wls

var = 3*Exp[t] - 4*t;
Export["test.txt", var];

From the shell

wolframscript -file test.wls

you might want to use ImportForm[] or other form if the text form output is not to your liking (for ex: inputform uses ‘/’ for division with (()), while another form (standard?) uses numerator --------- denominator spaced for easy viewing on 3 lines)