From SQL*Plus 12.2, you can use
SET MARKUP CSV {ON|OFF} [DELIMI[TER] character] [QUOTE {ON|OFF}]
e.g. (using all defaults)
set markup csv on
Or, if your command line is able to launch a web browser, you can set markup html, save to a file and open that in a browser. (I realise you asked for CSV format so this may not be any use to you, but it's a neat trick so I'm sharing it anyway.)
https://uhesse.com/2011/06/30/sqlplus-output-in-nice-html-format/
For example, save the following as html.sql (this example is for Windows, so you'll need to replace the start command with your Linux equivalent):
set termout off feedback off
set markup html on head "<title>SQL*Plus Output &_user@&_connect_identifier &_date</title> -
<style> -
html { -
font-family: consolas, monospace; -
font-size: 9pt; -
background-color: #dce1e9; -
} -
table, td, th { -
text-align: left; -
vertical-align: top; -
border: 1px solid #808090; -
background: white; -
padding: .5em .6em; -
} -
table { -
border-collapse: collapse; -
margin-top: 1.2em; /* space above table itself */ -
margin-bottom: 1.2em; -
border-width: 3px; -
margin-bottom: 1em; -
} -
td { -
margin: .2em; -
font-size: 80%; -
} -
th { -
background: #f0f4fd; -
font-weight: bold; -
font-size: 95%; -
margin: .2em; -
padding-bottom: .4em; -
} -
</style>" -
body "" -
table "align='left' summary='Script output'" -
spool on entmap on preformat off
spool sqlplus_output.html
run
spool off
set markup html off spool off
host start sqlplus_output.html
set termout on feedback on
Then you can enter a query at the SQL prompt (without running it), then
@html
and the results will appear in your default browser.