Save

Save["filename",symbol]

appends definitions associated with the specified symbol to a file.

Save["filename","patt"]

appends definitions associated with all symbols whose names match the string pattern "patt".

Save["filename","context`"]

appends definitions associated with all symbols in the specified context.

Save["filename",{object1,object2,}]

appends definitions associated with several objects.

Details

  • Save uses FullDefinition to include subsidiary definitions.
  • Save writes out definitions in InputForm.
  • Save uses Names to find symbols whose names match a given string pattern.
  • You can use Save["filename","s"] to write out the definition for the value of a symbol s itself.
  • Save works with local and cloud objects.
  • Save[File["filename"],] is also supported.

Examples

open allclose all

Basic Examples  (2)

Create a temporary file:

In[1]:=
Click for copyable input
Out[1]=

Store a value in a variable:

In[2]:=
Click for copyable input

Save the value of the variable in a file:

In[3]:=
Click for copyable input

Loading the file restores the value of a:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
In[6]:=
Click for copyable input
Out[6]=
In[7]:=
Click for copyable input

Create multiple definitions to save:

In[1]:=
Click for copyable input

Save the definitions to standard out to see how they would be written to a file:

In[2]:=
Click for copyable input

Scope  (1)

Generalizations & Extensions  (2)

Applications  (1)

Properties & Relations  (2)

See Also

PutAppend  Get  DumpSave  FullDefinition  SaveDefinitions  CloudSave

Tutorials

Introduced in 1988
(1.0)
| Updated in 2016
(11.0)