簡體   English   中英

如何設置Echo開/關以進行文件操作

[英]How to set Echo on/off for file manipulation

我在空白行上打開/關閉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(始終有效。

if "!test!" == [] if "!test!" == []永遠不會匹配。 不要使用空格。

If "%string%"=="" ,則字符串為空。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM