Bob Proulx a écrit :
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



Thank you Bob

I knew that one but I simply wondered why wc had that behavior.

Cheers,


Iram.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to