Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list of expressions in a text file. I would like mathematica to evaluate and export the results at the end of the same file or in a new file. The expressions are in seperate lines in the text file.

share|improve this question
cat a.txt


expr = Import["a.txt"]

Mathematica graphics

result = ToExpression[expr]

Mathematica graphics

Export["result.txt", result]


>cat result.txt 

Mathematica graphics

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.