How do I save command output to a file?

Use the core > <file> operator: append is the default, while -r replaces the destination.

Append by default

dns google.com > save.log still prints the DNS result in the terminal and appends the same textual representation to save.log in the current lil-terminal directory. After the result, the terminal prints the resolved destination path. Repeating the command appends another result instead of deleting the earlier data.

Replace or state append explicitly

Use -r after the destination to replace it: dns gmail.com > save.log -r. -a explicitly requests the default append mode. Quote a destination that contains spaces. The operator is handled by the core, so modules do not need separate export flags merely to preserve what they display.

What can be redirected

Only redirectable textual results are written. Interactive editors, secret prompts, downloads and browser-control events are not converted into files. Commands that already use > inside their own grammar keep that syntax; redirection is recognized as the final output operator.

Reuse the last result

history -o returns the last redirectable textual result kept in the current PHP session. history -o > history.log saves it, and history -o > history.log -r replaces the file. The desktop Ctrl/Command+S shortcuts invoke these same commands.

Why values use a colon

In the current grammar, > is reserved for core output redirection. Commands that accept a value use :: ini app.ini -w key : value, json app.json -w path : value, ses path : value, attr file key : value and db : SELECT .... This removes the ambiguous case and lets command ... > file mean the same thing everywhere. An older installed module is detected and produces a migration message instead of silently redirecting the wrong text.

Examples

dns google.com > save.log
dns gmail.com > save.log -r
env > "logs/env current.log" -a
history -o > history.log
history -o > history.log -r

Related documentation

← Back to FAQ