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.

Required fields*

3
  • The first form isn't quite right in all cases. printf '%s\n' "$var1" will more reliably emit the content faithfully and correctly than echo "$var1" will. Commented Nov 8, 2015 at 16:41
  • @CharlesDuffy: Can you give an example? Commented Nov 8, 2015 at 16:42
  • Sure: var1=-n (in many versions; the POSIX spec makes this behavior implementation-defined). And if you're following the POSIX spec for echo, then any string with a literal backslash likewise results in implementation-defined output. Commented Nov 8, 2015 at 16:43