Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我尝试这个时:
echo "hi" | wc -c
我希望字符数为 2,但实际上我得到了 3。有人可以解释为什么它不是 2?
echo 默认会在输出后添加一个换行符。使用echo -n来避免这种情况。wc -c 也会计算字节数,使用 wc -m 来计算字符数。