سؤال

When I try this:

echo "hi" | wc -c

I'd expect a character count of 2, but I actually get 3. Can someone explain why it isn't 2?

هل كانت مفيدة؟

المحلول

echo will add a newline characterafter the output by default. Use echo -n to avoid this. Also wc -c will count bytes, use wc -m for character count.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top