WolframScript Tutorial

By Xah Lee. Date: . Last updated: .
Xah Talk Show 2021-11-20 Bash vs PowerShell vs WolframLang

This is a tutorial on using WolframScript to do typical linux shell scripting tasks, such as bash and PowerShell.

Download Wolfram Engine

Download Wolfram Language Free

What is WolframScript

WolframScript is a command line interface to Wolfram Engine. It lets you run WolframLang code from a terminal.

Wolfram Engine comes with WolframScript bundled.

Run WolframScript in terminal

type wolframscript

WolframScript math 2021-10-22 FYBv
WolframScript math 2021-10-22

Exit WolframScript

Type Exit or Quit.

Run a WolframLang code

wolframscript -code "3+1"

Run a WolframLang file

wolframscript -file test.wls

Get help for options

wolframscript -h

Here's a complete list:

-h, -help
Print help text.
-c WL, -code WL
Give Wolfram Language code to execute.
-f, -file PATH
Give a file containing Wolfram Language code to execute.
-a, -api URL|UUID
Use an API at the specified URL, or coming from a cloud or local object with the specified UUID. Provide arguments in the form 'key=value' following '-args'.
-fun, -function WL
Use a function whose arguments are the strings given using '-args' interpreted as the types given using '-signature'
-o, -cloud [CLOUDBASE]
Execute code in the cloud, using the specified cloud base. By default, cloud base is https://wolframcloud.com
-l, -local [KERNELPATH]
Execute code locally, using the specified path to the Wolfram Engine kernel. By default, KernelPath uses the most recent version of the Wolfram Language found on the local system.
-- ARGS...,-args ARGS...
Used with '-api' or '-function' to provide arguments.
-s, -signature TYPE...
Used with '-function' and '-args' to specify interpreter types for provided arguments.
-v, -verbose
Print additional information during execution.
-activate [KEY]
Activate the Wolfram Engine through the cloud or with a key.
-entitlement ID
Activate the Wolfram Engine using on-demand licensing with the given license entitlement ID.
-authenticate [ID PASS]
Authenticate with the cloud, specifying a particular Wolfram ID and password, and prompting if they are not given. Different authentication can be specified for different clouds.
Disconnect from the cloud, removing authentication information.
-configure [KEY=VAL...]
Configure WolframScript by specifying values for particular configuration variable keys. If no keys are given, this prints the current configuration.
Print version of WolframScript.
-username USERNAME
Give username for authentication.
-password PASSWORD
Give password for authentication.
-permissionskey KEY
Give a permissions key used to authorize access to a cloud deployed API.
-k, -noverifypeer
Disable peer certificate verification when interacting with the cloud.
-timeout SECONDS [VALUE]
Specify the number of seconds to allow for execution. Return value if time is exceeded.
-charset ENCODING
Use encoding for output. Encodings can be None to output raw bytes, or any entry in $CharacterEncodings except "Unicode". The default is to infer the value from the terminal's language settings.
-format TYPE
Specify the format in which to give output. Any format understood by Export can be used.
-print [all]
When running a script, print the result from executing the last line of the script, or each line if all is given.
Execute code on each line of standard input that is read.
-script ARGS...
Counterpart to wolfram -script, additionally sets up $ScriptCommandLine.

Wolfram Language File Name Extension

WolframLang Tutorial for Shell Tasks

WolframLang Tutorial for Shell Tasks

WolframLang in Depth


Comment, Print




Expression, Atom, Head





Data Structure


Pattern Matching


Shell Tasks