Forward slash vs backward slash for file path in git bash

后端 未结 4 1299
孤街浪徒
孤街浪徒 2021-01-14 08:36

I am running these two commands in Git bash.

Why they behave differently? Aren\'t they supposed to do the same thing or am I missing something?

4条回答
  •  执笔经年
    2021-01-14 09:26

    Backslash is an escape character used to escape meta characters. This means you need to escape the escape:

    D:\\Patches\\afterWGComment.txt
    

    Alternative you can put your string in single quotes, which will make all characters literal:

    'D\Patches\afterWGComment.txt'
    

    Some meta characters: *, ~, $, !, ...

提交回复
热议问题