For an assignment, I need to run a few commands in the terminal and save the entire session - both the output and commands - to a text file. Piping the Command Prompt commands saves only the output; in a Linux terminal I'd use the "script" command, but git-bash cannot find this command.

  • From a Windows command shell you can just copy the commands and output and save in a text file. I do this all the time when including example output in my answers. – DavidPostill Apr 3 '19 at 19:37
  • look up how to copy and paste from the window – barlop Apr 3 '19 at 22:38

Since script command is available for Linux. Windows Command Prompt does not have script command. Git-Bash is also modified and formatted form of Windows Command Prompt so it also does not have script command. To have it Login to Linux machine from Git-Bash and proceed as per instruction. So to use script command:

  1. Either Login to a Linux Machine and run the script command and then run the command you need to run.
  2. Or do a ssh login on to a remote Linux Machine from Git-Bash and proceed further.

If want to same behavior on Windows:

  1. Write equivalent batch script for windows command prompt. By default command prompt first echo the command and then its output unless you use @echo off at the first line of batch script.
  2. Find a windows version of script command if someone have taken the pain to write for you still the command run on Linux can not be fully available on windows.
  • So if I understand you correctly, there is no built-in equivalent to "script" in the Windows environment? – twelve_fluid_ounces Apr 4 '19 at 3:15
  • Yes, there is no built-in but windows by default echos all the command before its execution. One can check that there is no "@echo off" is set. This will disable echoing. – Amarjeet Sharma Apr 4 '19 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.