Answer: Use a Bash command substitution to capture Copilot's output in a variable, for example: result=$(copilot -p 'What version of Node.js does this project require? \ Give the number only. No other text.' -s), then echo the result. Status: Check failed Entry: tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable Revision: 1 Digest: sha256:2a7731e77ff4ccd7 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:23:46Z Last changed: 2026-11-13T03:23:46Z Last verified: 2026-11-17T13:17:55Z Last attempt: 2026-11-20T13:01:55Z (failed) Next check: 2026-11-20T14:01:55Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of capture command | result=$(copilot -p 'What version of Node.js does this project require? \ Give the number only. No other text.' -s) | [1] | 2026-11-17 echo command | echo "Required Node version: $result" | [1] | 2026-11-17 shell | Bash | [1] | 2026-11-17 Sources: [1] GitHub. "Running GitHub Copilot CLI programmatically - GitHub Docs". https://docs.github.com/en/copilot/how-tos/copilot-cli/automate-copilot-cli/run-cli-programmatically Role: primary. Accessed: 2026-11-17T13:17:55Z Quote: "result=$(copilot -p 'What version of Node.js does this project require? \ Give the number only. No other text.' -s)" (Supports: capture command) Quote: "echo "Required Node version: $result"" (Supports: echo command) Quote: "Capture Copilot's output in a variable Bash" (Supports: shell) Snapshot SHA-256: b172e865bca7f5e8448a4a5210bc0cd1cee618fe5e01557c75e67d1001bc0fb2 (captured 2026-11-16T12:45:26Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-16T12:45:27Z, so the values verified then were kept. Cross-check: not-available at 2026-11-17T13:17:55Z. No independent second source is configured for this entry Last successful check: 2026-11-17T13:17:55Z Last attempt: 2026-11-20T13:01:55Z (failed) Notes and limitations: Extracted automatically from a single official source (section "Capture Copilot's output in a variable"). Related: https://latestn.com/tool/github-copilot/commands-and-shortcuts/chronicle-command-options What does the /chronicle slash command do in GitHub Copilot CLI and which subcommands exist? https://latestn.com/tool/github-copilot/commands-and-shortcuts/chronicle-insights-instructions How do I use /chronicle in GitHub Copilot to generate insights and feed them into copilot-instructions.md? https://latestn.com/tool/github-copilot/commands-and-shortcuts/clean-up-voice-prompts How do I clean up or edit voice-entered prompts in GitHub Copilot CLI? https://latestn.com/tool/github-copilot/commands-and-shortcuts/available-slash-commands What slash commands are available in the GitHub Copilot app? https://latestn.com/tool/github-copilot/commands-and-shortcuts/cancel-and-rollback How do I cancel operations and roll back changes in GitHub Copilot CLI? https://latestn.com/tool/github-copilot/commands-and-shortcuts/cancel-operation How do I cancel a running operation in GitHub Copilot CLI? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-18T12:56:05Z | check-failed | Extraction did not pass verification: answer does not contain any extracted value | — 2026-11-13T03:23:46Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable POST: https://latestn.com/dispute/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I capture GitHub Copilot CLI output in a shell variable? Revision 1, last verified 2026-11-17T13:17:55Z. https://latestn.com/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable (accessed 2026-11-21T09:54:44Z). @misc{LatestN_tool_github_copilot_commands_and_shortcuts_capture_cli_output_variable_r1, title = {How do I capture GitHub Copilot CLI output in a shell variable?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable}}, note = {Revision 1; digest sha256:2a7731e77ff4ccd7; last verified 2026-11-17T13:17:55Z; accessed 2026-11-21T09:54:44Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/github-copilot/commands-and-shortcuts/capture-cli-output-variable