writes expr to a file.


writes a sequence of expressions expri to a file.


creates an empty file with the specified name.

Details and Options

  • Put starts writing output at the beginning of the file. It deletes whatever was previously in the file.
  • Put inserts a newline (line feed) at the end of its output.
  • expr>>filename is equivalent to expr>>"filename". The double quotes can be omitted if the file name is of the form specified in "Operator Input Forms".
  • It is conventional to use names that end with .m for files containing Wolfram Language input.
  • Put works with cloud and local objects.
  • Put by default writes expressions in InputForm.
  • Put[OutputForm[expr],"filename"] generates OutputForm.
  • Put[,File["file"]] is also supported.


open allclose all

Basic Examples  (1)

Save a computed value in a temporary file:

Set the current directory to one for temporary files:

Put the value of a into a file:

The file now contains the value:

Reset the directory:

Scope  (3)

Local objects can be used with Put and Get to store expressions persistently:

Cloud objects can be used with Put and Get to store expressions in the cloud:

Put expression in the file specified by the File object:

Introduced in 1988
Updated in 2014