WC在OSX - 返回包含空格 [英] WC on OSX - Return includes spaces

查看:284
本文介绍了WC在OSX - 返回包含空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行像在OSX终端字数命​​令厕所-c file.txt的我得到的答案如下包含空格的答案之前补齐。有谁知道为什么会这样,不然我怎么能prevent呢?

When I run the word count command in OSX terminal like wc -c file.txt I get the below answer that includes spaces padded before the answer. Does anyone know why this happens, or how I can prevent it?

    18000 file.txt

我希望得到:

18000 file.txt

这会出现使用bash或Bourne shell。

This occurs using bash or bourne shell.

推荐答案

我想这是获得输出很好地排队的方式,而据我所知,是没有选择的WC进行微调的输出格式。

I suppose it is a way of getting outputs to line up nicely, and as far as I know there is no option to wc which fine tunes the output format.

您可以通过管道通过 SED摆脱他们的pretty轻松的/ ^ * // ,例如

You could get rid of them pretty easily by piping through sed 's/^ *//', for example.

有可能是一个更简单的解决方案,这取决于你为什么要摆脱他们。

There may be an even simpler solution, depending on why you want to get rid of them.

这篇关于WC在OSX - 返回包含空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆