I’m trying to use the Windows batch FOR command.
How do I specify a TAB character as a delimiter? The default is space and tab, but I want tab only.
I’ve tried this, but it doesn’t work:
FOR /F "tokens=3 delims=^T" %i in (test.txt) do @echo %i
It seems to be splitting on the T character instead of a tab. I’ve also tried a literal pasted into the command prompt, but I get a syntax error.
You need a literal tab character in the quoted options string. The literal TAB works both in a batch file and on the command line.
If you are attempting to type a TAB into the command line, then file name completion may be thwarting your efforts. You can disable name completion by using
CMD /F:OFF. You will then be able to enter a literal TAB character.You can also run into problems trying to enter a TAB into a batch script depending on the text editor that you use. Some programmer’s editors have settings that automatically convert TABs into spaces. You will need to make sure your editor is not doing that.
So you just need to change your
"tokens=3 delims=^T"string to use a TAB literal instead of^T