WHERE is the documentation that explains the apparently anomalous behaviour of the equal sign below?

STEPS TO REPRODUCE (at a command prompt):

example with ECHO:

H:\BUGS>echo abc > a-b.txt
H:\BUGS>echo cde > c=d.txt
2016-03-13  19:54  6 a-b.txt
2016-03-13  19:54 12 c
H:\BUGS>type a-b.txt
H:\BUGS>type c
cde =d.txt

file c:

c d e   = d . t x t    

file a-b.txt:

a b c     

HOWEVER (here the '=' becomes part of the valid file names if i use quotes):

H:\BUGS>ren a-b.txt a=b.txt
The syntax of the command is incorrect.

H:\BUGS>ren a-b.txt "a=b.txt"
H:\BUGS>ren c       "c=d.txt"
2016-03-13  19:54   6 a=b.txt
2016-03-13  19:54  12 c=d.txt

an equal sign is a valid file name character.

FWIW, it appears that a '=' not in quotes has a bizarre special meaning on a DOS command line.

OTOH, the '=' is a valid file name character.

"Naming Files, Paths, and Namespaces"

using Windows 8.1


H:\BUGS>echo def > "d=e.txt"
2016-03-13  20:36 6 d=e.txt
H:\BUGS>type "d=e.txt"

the syntax above works.

end edit.

edit #2:

Michael Frank helped me find more information.

His information enabled me to locate an interesting SO article "cmd- comma to separate parameters Compared to space?"

H:\BUGS>type Frank.cmd
@echo %1/%2/%3

H:\BUGS>Frank 1 2 3

H:\BUGS>Frank 1=2=3

H:\BUGS>Frank 1;2;3

H:\BUGS>Frank 1,2,3

H:\BUGS>Frank 1/2/3

in the above, various characters are used as delimiters.

when / was used as a delimiter above, an extra / is emitted; that would be a bug imho.

at "cmd- comma to separate parameters Compared to space?", Tim Robinson wrote "on Windows, programs are responsible for parsing their own command lines. The shell parses redirects and pipes, then passes the rest of the command line to the program in one string"

BOTTOM LINE: it appears that where a delimiter is needed, = acts as a delimiter; in some cases = causes a syntax error, in other cases = is simply an equal sign.

end edit #2.

  • searching for an explanation via Google was unsuccessful; while the workaround resolves the problem, for me finding this in the documentation is important; any help is appreciated.
    – gerryLowry
    Mar 14 '16 at 0:41
  • Escape the = with a ^. For example: echo cde>c^=d.txt. Mar 14 '16 at 0:42
  • @MichaelFrank yes, that also works; thank you; however, what i really wish to know is why that = behaves like this; = is not one of the special characters listed here "Naming Conventions" ~~ < (less than); > (greater than); : (colon); " (double quote); / (forward slash); ` (backslash); |` (vertical bar or pipe); ? (question mark); *(asterisk)
    – gerryLowry
    Mar 14 '16 at 0:54
  • See my answer below, but basically it is a delimiter character, used to separate commands. Mar 14 '16 at 0:55

The = character is a delimiter, functionally it seems to be the same as a space . As you can see in the example below:

c:\NotBackedUp>echo abc>d efg.txt

c:\NotBackedUp>type d
abc efg.txt

Likewise, = will do the same thing:

c:\NotBackedUp>echo abc>d=efg.txt

c:\NotBackedUp>type d

Let's take a look at your first command: echo cde > c=d.txt

Starting off, you invoke the echo command, then pass it a value cde to insert into file c. Because = is a delimiter and you haven't told echo where to send the next string d.txt, it defaults to the previous file: c.

You can get around this by either quoting your output name:

c:\NotBackedUp>echo abc>"d=e.txt"

or by escaping the delimiter with ^:

c:\NotBackedUp>echo abc>d^=e.txt

Both of these will create a file d=e.txt with contents abc.

Further information about Delimiters

  • thank you for the link to the Simon Sheppard site [ss64.com](ss64.com) ... see my edit #2. You are correct in that sometimes = acts like a delimiter. For me, it is surprising that Microsoft has not documented this; my preference would have been to have found documentation from Microsoft; regardless, because Simon Sheppard's website directed me to a better understanding, i'm marking your answer as the answer.
    – gerryLowry
    Mar 14 '16 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.