New answers tagged wc
By default, echo will print a newline character (\n) after the string (which is why you see the shell prompt on the next line instead of the same line where abcd is printed.) You can try adding a -n parameter to echo to disable the trailing newline character. echo -n abcd | wc -c 4
If you run echo without the -n option, it writes a newline character after the arguments. Otherwise, if you typed echo foo, your next shell prompt would appear to the right of the foo. So wc is counting the newline. How can I prevent echo from printing that? echo -n abcd | wc -c
echo print newline (\n) at end line echo abcd | xxd 0000000: 6162 6364 0a abcd. With some echo implementations, you can use -n: -n do not output the trailing newline and test : echo -n abcd | wc -c 4 With some others, you need the \c escape sequence: \c: Suppress the <newline> that otherwise follows the final argument in the ...
Top 50 recent answers are included