Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

If I print a string to a file it also adds quotation marks to the string. Here is an example:

a = "test \t test"
a >> file

How can I remove those? And is it possible to use \t for a tabulator?

share|improve this question
see OpenWrite[] and WriteString[] – george2079 Sep 20 '13 at 17:27
Depending on your problem, Export offers many formatting options that may be useful. – Yves Klett Sep 21 '13 at 6:51

I think what you may be looking for is the following

a = "test\ntest";
fn = "test";
Put[OutputForm[a], fn];
FilePrint @ fn

As the documentation for Put states: "Put by default writes expressions in InputForm." So you have to wrap the expression you are writing out with OutputForm.

Note: you could rewrite the above code as

a = "test\ntest";
OutputForm[a] >> "test"
FilePrint @ "test"

but I personally don't use >> -- I have a dislike of it because it uses non-standard evaluation.

Also, I should note that I changed \t to \n only because \n makes for a better demonstration effect.

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.