Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save multiple command results to txt file

I have given a bat file that I should run on development server which does some updates.

It has multiple commands and I would like to keep the results in txt file.

Should I add after each command >> result.txt or I can add it somewhere in the end of bat file and everything will be written in that?

like image 398
user3801813 Avatar asked Sep 28 '22 06:09

user3801813


1 Answers

You have four options:

  • Run the batch file at the command line like: myBat.bat >> outPut.txt

  • Script the above in another batch file and run that

  • Insert the >> after each command ( Note: the >> appends to file, while > overrides existing text output file)

  • Enclose all relevant lines in parentheses and script >> result.txt once at the end of the script

like image 132
MiiinimalLogic Avatar answered Oct 03 '22 08:10

MiiinimalLogic