Skip to main content
added 70 characters in body
Source Link
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

It works, but running echo -e doesn't output anything in Bash unless both the posix and xpg_echo options are enabled, as the -e is then interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes
      -E        explicitly suppress interpretation of backslash escapes

Use

printf "%s\n" "$var"

instead.

And as cas notes in a comment, Bash's declare -p var (typeset -p var in ksh and, zsh and yash (and bash)) can be used to tell the exact type and contents of a variable.

See: Why is printf better than echo?

It works, but running echo -e doesn't output anything in Bash, as the -e is interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes
      -E        explicitly suppress interpretation of backslash escapes

Use

printf "%s\n" "$var"

instead.

And as cas notes in a comment, Bash's declare -p var (typeset -p var in ksh and zsh) can be used to tell the exact type and contents of a variable.

See: Why is printf better than echo?

It works, but running echo -e doesn't output anything in Bash unless both the posix and xpg_echo options are enabled, as the -e is then interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes
      -E        explicitly suppress interpretation of backslash escapes

Use

printf "%s\n" "$var"

instead.

And as cas notes in a comment, Bash's declare -p var (typeset -p var in ksh, zsh and yash (and bash)) can be used to tell the exact type and contents of a variable.

See: Why is printf better than echo?

added 230 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

It works, but running echo -e doesn't output anything in Bash, as the -e is interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes
      -E        explicitly suppress interpretation of backslash escapes

Use

printf "%s\n" "$var"

instead.

And as cas notes in a comment, Bash's declare -p var (typeset -p var in ksh and zsh) can be used to tell the exact type and contents of a variable.

See: Why is printf better than echo?

It works, but running echo -e doesn't output anything in Bash, as the -e is interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes

Use

printf "%s\n" "$var"

instead.

See: Why is printf better than echo?

It works, but running echo -e doesn't output anything in Bash, as the -e is interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes
      -E        explicitly suppress interpretation of backslash escapes

Use

printf "%s\n" "$var"

instead.

And as cas notes in a comment, Bash's declare -p var (typeset -p var in ksh and zsh) can be used to tell the exact type and contents of a variable.

See: Why is printf better than echo?

Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

It works, but running echo -e doesn't output anything in Bash, as the -e is interpreted as an option:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
    
    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.
    
    Options:
      -n        do not append a newline
      -e        enable interpretation of the following backslash escapes

Use

printf "%s\n" "$var"

instead.

See: Why is printf better than echo?