Skip to content

Variables in lnav scripts (not env vars) #1186

Answered by tstack
ewan-chalmers asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a SQL SELECT statement to set variables, like so:

;SELECT 1 AS one, 'two' AS two

And, then reference then in commands that support variable substitution, like :echo:

:echo $one and $two

Some commands do not perform substitutions, so you need to use :eval.

You can also reference the variables in subsequent SQL statements:

;SELECT $one, $two

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ewan-chalmers
Comment options

Answer selected by ewan-chalmers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants