2009-07-17, 13:09(-06), Eric Blake: > > According to Huang Tao on 7/17/2009 9:46 AM: >> I'm not sure whether it is a bug >> how can i echo the text string "-e" barely ( or "-n", "-E") >> i tried >> $echo "-e" >> $echo '-e' >> and some other inputs, all of which produced no outputs. > > Instead of using echo (which POSIX itself admits is fraught with > portability problems), use printf: > > printf -- '-e\n' [...]
Note that it's a known non POSIX-conformance of bash. POSIX is explicit that echo -e Should output "-e\n". With bash, you can do it with: echo -ne '-e\n' Or echo -n '-e ' None of which is POSIX (the behavior being unspecified in both cases), so the advise of using printf is certainly a good one for portability. -- Stéphane