Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • ... and then there are some oddities: for exemple: printf "\ntest" will insert a newline before "test", even though "\n" should have been translated to "n" by the shell as it is whithin double quotes... (so the expected result should be, for "\ntest", "ntest". We should get the habit to write: printf "\\ntest" or printf '\ntest', but somehow I see a lot of script relying on the oddity instead. Commented May 28, 2018 at 13:35
  • 1
    @OlivierDulac: according to dash manual page: The backslash inside double quotes is historically weird, and serves to quote only the following characters: $ ` " \ <newline>. Otherwise it remains literal. Commented Mar 3, 2023 at 16:13
  • @MoonSweep : indeed, at the time of the above comment I thought most "\X" would be translated to "X", but lots of time "\" is kept as-it (and then printf sees "\n" and prints a newline, as it should). I was confused about "\X" vs '\X', thinking they would almost always behave differently. Commented Mar 3, 2023 at 16:27