From: Brian Candler Date: 2009-05-12T16:37:42+09:00 Subject: Re: question to write \4 into file Cheyne Li wrote: > Thanks. After puting 8 slashes, the path is correctely written in the > file...speachless... Then there is something else which is doing a third level of dequoting. I can't say what this is, since you don't show your code. Perhaps you are passing the string to a shell, e.g. using backticks, %x{...}, system(), IO.popen or similar. In this case, the shell also treats backslash sequences specially. irb(main):001:0> str = "\\\\" => "\\\\" irb(main):002:0> puts str \\ => nil irb(main):003:0> system("echo #{str}") \ => true Here, str is actually two characters (backslash followed by backslash). But the shell treats this as a single backslash-escaped character. You can avoid this problem by not getting the shell involved. If you pass multiple arguments to system() then it invokes the target program with the arguments exactly as given, without invoking the shell at all. irb(main):004:0> system("echo", str) \\ -- Posted via http://www.ruby-forum.com/.