bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wc


From: Bob Proulx
Subject: Re: wc
Date: Fri, 12 Jun 2009 07:56:39 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

Iram CHELLI wrote:
>     wc FILE | cut -d " " -f 2
>
> it usually works but sometimes wc outputs the result in a different  
> formatting, that is, I have to do a cut -d " " -f 3 to get the wc.

The output format for the wc on different systems will produce a
differing number of leading spaces.  Counting on a particular number
of spaces isn't portable.  This is done to line up the columns to make
them more human readable.  Because of this 'cut' isn't the right tool
for the task.  Awk is a better fit.

  wc FILE | awk '{print$2}'

> This is not very convenient that the wc program shall not return results  
> in a fixed formatting.

But so it has been for decades.  It has been for too many years to
change it now.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]