Using bat script to write a text file: missing character

I am using a bat script to try to write multiple lines to a text file. However, in one case, the character is discarded, which I want to write.

Here is the code:

@echo off
@echo san policy=onlineall> test.txt
@echo select disk 1>> test.txt
@echo online disk>> test.txt

Here is the resulting text file (test.txt)

san policy=onlineall
select disk 
online disk

Why is the "1" missing in the resulting code?

+4
source share
2 answers

Logging out 1with a carriage will also work:

@echo off
@echo san policy=onlineall> test.txt
@echo select disk ^1>> test.txt
@echo online disk>> test.txt
+3
source

You can redirect various streams with >. They differ in numbers, 0 - stdin, 1 - stdout, 2 - stderr, to list predefined ones.

, , 1>, , 1 ( ). - , . :

>>test.txt echo select disk 1
+3

All Articles