4 ms·
> And what if I actually wanted to print "-n"? There's no way to do it. Good point.I first tried "echo \-n", and "echo -- -n". No luck. I get the correct visua
by bch 15y ago
> And what if I actually wanted to print "-n"? There's no way to do it.
Good point.I first tried "echo \-n", and "echo -- -n". No luck. I get the correct visual effect with "echo - ^Hn" (^H generated with ^V, backspace), but the embedded backspace is still actually part of the output :P "echo - ^Hn | col" strips it. Seems like quite an oversight, really, and is prime example of how bugs sneak into code via features.
edit: ilikejam solved it w/o leaning on other tool. As he said "not pretty", but simpler than what I have: http://news.ycombinator.com/item?id=2781034 http://news.ycombinator.com/item?id=2781034
- pyre 15y agoUse the source... ;-) % env POSIXLY_CORRECT=1 echo -n -n Also note that if your shell is Bash, then your echo is a built-in: % type echo echo is a shell builtin That's why 'env' is necessary.
- bch 15y agoYour Linux is showing ;). kamloops$ uname -s NetBSD kamloops$ echo $0 sh kamloops$ env POSIXLY_CORRECT=1 echo -n kamloops$