Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Cute, but does not work with bash builtin echo, for which two -n's equals one -n.

   bash-3.2$ echo -n -n foo
   foobash-3.2$ 
Like always with echo -n, no matter what you try, it's not portable.


So...

[dave@mini ~]$ echo -n "-n foo

> "

-n foo

[dave@mini ~]$

Easy!


All respect for persistence, but that's not a solution, because the OP wanted to echo just "-n". I put the foo in to better show what was happening.

For similar reasons,

  echo "" -n
does not work, etc.


' echo -n "-n

" ' works fine with the bash built-in. It echo's "-n".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: