Skip to content
Advertisement

Keep previous information when running an executable from command lines

In Windows when I run an executalbe from command line, for example, abc.exe -i abc.bmp >output.txt, all the output of the program will be put in the text file. However, all the previous contents in the text file will also be destroyed. So if I run the following commands sequentially,

abc.exe -i abc.bmp >output.txt

abc.exe -i def.bmp >output.txt 

Only the information when running the second file will be kept in output.txt. So my question is how I can also keep the previous information in the txt file.

Advertisement

Answer

Use >> to append to a file.

abc.exe -i abc.bmp >output.txt

abc.exe -i def.bmp >>output.txt 

The first line will create or clear the file. The second line will append to it.

Advertisement