本文介绍了如何禁用/F的eol和delims选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 带有/F开关的for命令用于解析文本字符串行(文字字符串,从文本文件读取或从命令行输出中检索),并将每个文本字符串解析为一个或多个标记.如何在不替换任何字符或忽略任何行的情况下原样获得一行文本?我知道for /F "delims=" %L in (*) do echo."%L"会返回未编辑的每个已分析(非空)行.但是,由于eol选项默认为;,因此以该字符开头的每一行都将被忽略.如果我使用for /F "tokens=* eol=" %L in (*) do echo."%L",则 [ [Edit: This claim is not true, "eol=" does not disable the eol option, but it defines " as the eol character!], but the delims option defaults to space and tab, so any leading spaces and/or tabs become removed.(Use %%L within batch files. The * stands for any valid source of text string here.)So my question in other words: is there a way to specify no delims and no eol characters?I tried to specify two option strings ("eol=" "delims=") but such results in a syntax error. So does option string "eol=delims=".Note: This problem does not persist when tokenizing, that is, when the delims option is set, because that seems to be applied with a higher priority than eol (strangely but luckily), so you can "hide" eol behind delims by specifying a delims character also as eol. 解决方案 1) you will be never able to force bat to not ignore empty / delimiter-only lines.This can be (sort-of) worked around by piping to findstr /R /N "^" command and use options like "tokens=1* delims=:" and get only the second token2) To deactivate eol and delim at the same time you can use this syntax:For /f tokens^=*^ delims^=^ eol^= %%a in (file.txt) do echo.%%athough the empty lines still will be ignored. 这篇关于如何禁用/F的eol和delims选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 23:16