4 ms·
TIL: dash$ x="foo\nasd" dash$ echo "$x" foo asd dash$ printf "%s\n" "$x" foo\nasd dash$ zsh% x="foo\nasd" zsh% echo "$x" foo asd zsh%
by nequo 4y ago
TIL:
dash$ x="foo\nasd"
dash$ echo "$x"
foo
asd
dash$ printf "%s\n" "$x"
foo\nasd
dash$
zsh% x="foo\nasd"
zsh% echo "$x"
foo
asd
zsh% printf "%s\n" "$x"
foo\nasd
zsh%
bash$ x="foo\nasd"
bash$ echo "$x"
foo\nasd
bash$ printf "%s\n" "$x"
foo\nasd
bash$
- fragmede 4y agobash$ echo -e $x foo asd bash$
- norvvryo 4y agoEnlightening From POSIX: >echo - write arguments to standard output >If the first operand is -n, or if any of the operands contain a <backslash> character, the results are implementation-defined.
- deleted 4y ago[deleted]
- remram 4y agoWow, TIL indeed. That's conformant to the Single UNIX Specification as well: https://pubs.opengroup.org/onlinepubs/007908799/xcu/echo.html https://pubs.opengroup.org/onlinepubs/007908799/xcu/echo.htm...