batch echo pipe symbol causing unexpected behaviour

后端 未结 4 569
旧巷少年郎
旧巷少年郎 2020-12-06 09:37

I have a variable in my batch file and it contains the pipe symbol (this one: |) so when I echo the variable I get an error about a unrecognized internal/external command.

4条回答
  •  粉色の甜心
    2020-12-06 09:59

    You must escape the | character before you print the var. The following prints a|b

    @echo off
    
    set x=a^|b
    echo %x:|=^|%
    

提交回复
热议问题