Splunk® Enterprise

Search Reference

Acrobat logo Download manual as PDF

Splunk Enterprise version 6.x is no longer supported as of October 23, 2019. See the Splunk Software Support Policy for details. For information about upgrading to a supported version, see How to upgrade Splunk Enterprise.
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Acrobat logo Download topic as PDF



Saves search results to the specified CSV file on the local search-head in the $SPLUNK_HOME/var/run/splunk directory. Updates to $SPLUNK_HOME/var/run/*.csv using the outputcsv command are not replicated across the cluster.


outputcsv [append=<bool>] [create_empty=<bool>] [dispatch=<bool>] [usexml=<bool>] [singlefile=<bool>] [<filename>]

Optional arguments

Syntax: append=<bool>
Description: If append is true, the command attempts to append to an existing CSV file, if the file exists. If the CSV file does not exist, a file is created. If there is an existing file that has a CSV header already, the command only emits the fields that are referenced by that header. The command cannot append to .gz files.
Default: false
Syntax: create_empty=<bool>
Description: If set to true and there are no results, creates a 0-length file. When false, no file is created and if append=false, the file is deleted if it previously existed.
Default: false
Syntax: dispatch=<bool>
Description: If set to true, refers to a file in the job directory in $SPLUNK_HOME/var/run/splunk/dispatch/<job id>/.
Syntax: <filename>
Description: Specify the name of a CSV file to write the search results. This file should be located in $SPLUNK_HOME/var/run/splunk. Directory separators are not permitted in the filename. If no filename is specified, the command rewrites the contents of each result as a CSV row into the "_xml" field. Otherwise writes into a file (appends ".csv" to filename if filename has no existing extension).
Syntax: singlefile=<bool>
Description: If singlefile is set to true and the output spans multiple files, collapses it into a single file.
Default: true
Syntax: usexml=<bool>
Description: If there is no filename, specifies whether or not to encode the CSV output into XML. This option should not be used when invoking the outputcsv from the UI.


There is no limit to the number of results that can be saved to the CSV file.


Example 1: Output search results to the CSV file 'mysearch.csv'.

... | outputcsv mysearch

See also



Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the outputcsv command.

Last modified on 19 May, 2016

This documentation applies to the following versions of Splunk® Enterprise: 6.3.0, 6.3.1, 6.3.2, 6.3.3

Was this documentation topic helpful?

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters