Saved Bookmarks
| 1. |
Solve : How to create a txt file from a BATCH FILE? |
|
Answer» Hi All There needs to be a space before and after the >. Here is a session on WindowsNT Code: [Select]Microsoft(R) Windows NT(TM) (C) Copyright 1985-1996 Microsoft Corp. C:\use\qbasic>echo abc > z.txt C:\use\qbasic>echo def>>z.txt C:\use\qbasic>echo ghi >>z.txt C:\use\qbasic>echo jkl>> z.txt C:\use\qbasic>echo mno >> z.txt C:\use\qbasic> Here is the contents of z.txt after I substituted # for space: abc# def ghi# jkl mno######## Mac Oh... maybe not. But it's still easier to read IMO. Quote maybe not Maybe?? Anyway, the point to note is that any spaces before the redirection symbol will be written to the file. "Maybe" this is not important. But it's nice to be aware of. Mac "Maybe" I can be wrong. Let's not turn this into a flame war.Sometimes there does need to be a space between the redirection symbol and the file, like if you are REDIRECTING a number, or the last part of the string is a number. Even though the only streams defined are 1> (STDOUT) and 2> (STDERR), I BELIEVE the other NUMBERS are reserved. For example, the following would probably not work: echo 1 2 3>>z.txt echo 4 5 6>> z.txt echo The answer is 0>>z.txt Agreed. Also if you only want to trap errors copy a.dat b.dat 2>log.dat will work copy a.dat b.dat2>log.dat won't. Mac |
|