echo “-e” doesn't print anything

后端 未结 10 2181
谎友^
谎友^ 2020-12-03 22:11

I\'m using GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu). And this command:

echo \"-e\" 

doesn\'t print anything. I guess

相关标签:
10条回答
  • 2020-12-03 22:18

    Another alternative:

    echo x-e | sed 's/^x//'
    

    This is the way recommended by the autoconf manual:

    [...] It is often possible to avoid this problem using 'echo "x$word"', taking the 'x' into account later in the pipe.

    0 讨论(0)
  • 2020-12-03 22:26

    The one true way to print any arbitrary string:

    printf "%s" "$vars"
    
    0 讨论(0)
  • 2020-12-03 22:28

    After paying careful attention to the man page :)

    SYSV3=1 /usr/bin/echo -e
    

    works, on Solaris at least

    0 讨论(0)
  • 2020-12-03 22:28

    I like that one using a herestring:

    cat <<<"-e"
    
    0 讨论(0)
  • 2020-12-03 22:28
    /bin/echo -e
    

    works, but why?

    [resin@nevada ~]$ which echo 
    /bin/echo
    
    0 讨论(0)
  • 2020-12-03 22:31

    Another way:

    echo -e' '
    echo -e " \b-e"
    
    0 讨论(0)
提交回复
热议问题