Reputation: 18257
I used this question to strip the newline from a string, but I've encountered a problem on one host.
For some reason, /bin/echo -n foo
prints nothing on that host. I have no idea why that host behaves oddly. /bin/echo foo
works fine. It's not the terminal, since echo -n foo > /tmp/bar
also shows nothing.
/bin/echo --help
says that is should work:
Usage: /bin/echo [OPTION]... [STRING]...
Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of backslash escapes
-E disable interpretation of backslash escapes (default)
--help display this help and exit
--version output version information and exit
% /bin/echo --version
echo (GNU coreutils) 5.97
What can possibly cause this not to work? Could there be some strange buffering in this bash-shell?
Upvotes: 0
Views: 1019
Reputation: 263237
Based on information in comments, it appears that /bin/echo -n foo
is producing the expected output, but it's being overwritten by your next shell prompt. (Most likely it's your shell, not your terminal settings.)
You can demonstrate this by running
/bin/echo -n foo | wc
which should produce this output:
0 1 3
You can also try this:
/bin/echo -n foo ; sleep 5
This will delay your next shell prompt for 5 seconds, so you can see the output before it's overwritten.
(What shell are you using? What's the value of $PS1
?)
Upvotes: 2