How to pass backslashes argument to a script?
问题 I just want to append an user input argument in a text file. I'm using the following command: echo "$2" >> "./db.txt" $2 is expected to user to set a path like: D:\Projects\MyProject . It writes to the file, but with no backslashes. The result is: D:ProjectsMyProject I can't find anywhere how to fix that. I've tried using -e or -E params(taken from here) but it doesn't seems to make difference in this case. 回答1: You have to escape backslashes in the shell: \\ , or put the string in quotes.