windows - 如何为文件操作设置 Echo 开/关
问题描述
我echo
对空白行的开/关有疑问。我尝试了多种方法,包括echo
变量等。
这是我当前使用的代码以及日志和在我使用脚本解析记录后的当前输出,其中一些记录是空白的,我希望保持空白。
当前代码
for /f "skip=%skipTo% tokens=1,* delims=]" %%a In ('type %InputFile% ^| find /v /n ""') do (
set ip=%%b
set ip=!ip:!
set test=!ip!
echo !ip!
echo(!test!
if "!test!" == [] (
!test! >> E:\EPM_Cloud\LoadFiles\BUD_PLN\Security\GROUPS_USERS_CURRENT_LIST.csv
) else (echo %%b >> E:\EPM_Cloud\LoadFiles\BUD_PLN\Security\GROUPS_USERS_CURRENT_LIST.csv)
)
当前输出(请注意,我需要保留当前具有“ECHO 已关闭”的 3 个空白行)
#group_children
id,group_id,group_provider,user_id,user_provider
BL_LEAD,,,TestUser_2,LDAP_Directory_Provider
BL_LEAD,,,angelo.vergura@nrc.gov,LDAP_Directory_Provider
ECHO is off.
ECHO is off.
ECHO is off.
#group_children
id,group_id,group_provider,user_id,user_provider
NON_BL_LEAD,,,Christopher.George@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,Lindsey.Heeszel@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,Safa.Kaleem@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,Susan.Orbach@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,Tung.Truong@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,angelo.vergura@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,arodriguez,LDAP_Directory_Provider
NON_BL_LEAD,,,camason@huronconsultinggroup.com,LDAP_Directory_Provider
NON_BL_LEAD,,,jeffrey.sheldon@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,larry.mason@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,mary.moshier@nrc.gov,LDAP_Directory_Provider
NON_BL_LEAD,,,sreekanth.manne@nrc.gov,LDAP_Directory_Provider
ECHO is off.
ECHO is off.
ECHO is off.
当前日志- 执行此代码后(如您所见,这证明了为什么我在输出中得到它的空行?当没有空行时,您会得到结果,但它们没有显示在日志
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
解决方案
要在该行为空(或只有空格)时消除 ECHO IS OFF(或 ON)消息,然后只需使用ECHO(%%b
代替ECHO %%b
.
传统上,人们习惯于ECHO.
消除空白行的问题。但是有一些模糊的情况可能会导致问题。
ECHO(
总是有效。
推荐阅读
- python - 如果我在 Python 中将 .fit() 放在 GridSearchCV() 的末尾是否有可能?
- reactjs - Create-React-App .env 文件目录位置(非根)
- java - 如何一个接一个地接受两个输入并且第二个输出与第一个不同?
- python - 用于检查 Python 中是否存在奇怪 IP(不在白名单中的 IP)的脚本函数
- c# - SpecFlow 上下文注入线程安全吗?
- python - 2 实现棋盘的暗列表
- ubuntu - 在 qemu 下运行 xv6 遇到一些困难
- java - Wandering Robot - 在 Kickstart 中获得了 WA
- c# - Xamarin iOS 后台应用程序终止
- php - 如何从PHP中的字符串中的数组中找到确切的单词