wc anomaly - SCO

This is a discussion on wc anomaly - SCO ; # echo "abcde" > /tmp/foo # wc -m /tmp/foo (-c flag gives same results) 6 foo Am I going nuts, or is this a bug? File 'foo' has 5 characters, not 6 ... and no blank lines or spaces. If ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: wc anomaly

  1. wc anomaly

    # echo "abcde" > /tmp/foo
    # wc -m /tmp/foo (-c flag gives same results)
    6 foo

    Am I going nuts, or is this a bug?
    File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.

    If this is the way it's supposed to be, then
    how can one rely on its output except to remember
    to subtract 1 ?

    - Jeff H

  2. Re: wc anomaly

    Jeff Hyman typed (on Sat, Mar 29, 2008 at 03:16:23PM -0400):
    | # echo "abcde" > /tmp/foo
    | # wc -m /tmp/foo (-c flag gives same results)
    | 6 foo
    |
    | Am I going nuts, or is this a bug?
    | File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    |
    | If this is the way it's supposed to be, then
    | how can one rely on its output except to remember
    | to subtract 1 ?

    It has 6 characters, no mystery, 'wc' is not playing games with you.

    Run 'vi /tmp/foo' and see
    "/tmp/foo" 1/6
    at the bottom of your screen.

    Look at it with
    hd /tmp/foo
    or with
    od -c /tmp/foo

    If you want a five-byte file, there must be dozens of ways to create
    one in Unix; as you know, the 'echo' command is pretty variable among
    Unices, but as we are in comp.unix.sco.misc, here are two of those ways
    to get a five-byte file:
    echo -n abcde > /tmp/foo
    echo "abcde\c" > /tmp/foo

    --
    JP

  3. Re: wc anomaly

    Jeff Hyman wrote (on Sat, Mar 29, 2008 at 03:16:23PM -0400):

    | # echo "abcde" > /tmp/foo
    | # wc -m /tmp/foo (-c flag gives same results)
    | 6 foo
    |
    | Am I going nuts, or is this a bug?

    You're going (or staying) nuts.

    | File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    |
    | If this is the way it's supposed to be, then
    | how can one rely on its output except to remember
    | to subtract 1 ?

    If you execute:

    hd /tmp/foo

    you'll see there are 6 characters in it - "abcde" followed by "0a",
    the newline character.

    Bob

    --
    Bob Stockler +-+ bob@trebor.iglou.com +-+ http://members.iglou.com/trebor

  4. Re: wc anomaly

    Jeff Hyman wrote:
    > # echo "abcde" > /tmp/foo
    > # wc -m /tmp/foo (-c flag gives same results)
    > 6 foo
    >
    > Am I going nuts, or is this a bug?
    > File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    >
    > If this is the way it's supposed to be, then
    > how can one rely on its output except to remember
    > to subtract 1 ?


    echo adds a linefeed.

    --
    RGB

  5. Re: wc anomaly

    Bob Stockler typed (on Sat, Mar 29, 2008 at 03:53:42PM -0400):
    | Jeff Hyman wrote (on Sat, Mar 29, 2008 at 03:16:23PM -0400):
    |
    | | # echo "abcde" > /tmp/foo
    | | # wc -m /tmp/foo (-c flag gives same results)
    | | 6 foo
    | |
    | | Am I going nuts, or is this a bug?
    |
    | You're going (or staying) nuts.
    |
    | | File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    | |
    | | If this is the way it's supposed to be, then
    | | how can one rely on its output except to remember
    | | to subtract 1 ?
    |
    | If you execute:
    |
    | hd /tmp/foo
    |
    | you'll see there are 6 characters in it - "abcde" followed by "0a",
    | the newline character.
    |
    | Bob

    Guys,

    I know about the -n \c flags for echo... but no where and no time
    did I ever imagine what you so clearly explain above.

    Where I typically use 'wc' is if I run a classified or to rent some
    commercial space, or sell something, or hire someone. I use(d) the
    'wc' command to determine the cost of the ad by the character count.
    I never would have detected it except I tried it on one word.

    Looks like I've been getting "Oa'ed" for some time.
    Bobby... does this mean I'm "going" or "staying" nuts? :-)

    - Jeff H

  6. Re: wc anomaly

    Jeff Hyman wrote:
    > Bob Stockler typed (on Sat, Mar 29, 2008 at 03:53:42PM -0400):
    > | Jeff Hyman wrote (on Sat, Mar 29, 2008 at 03:16:23PM -0400):
    > |
    > | | # echo "abcde" > /tmp/foo
    > | | # wc -m /tmp/foo (-c flag gives same results)
    > | | 6 foo
    > | |
    > | | Am I going nuts, or is this a bug?
    > |
    > | You're going (or staying) nuts.
    > |
    > | | File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    > | |
    > | | If this is the way it's supposed to be, then
    > | | how can one rely on its output except to remember
    > | | to subtract 1 ?
    > |
    > | If you execute:
    > |
    > | hd /tmp/foo
    > |
    > | you'll see there are 6 characters in it - "abcde" followed by "0a",
    > | the newline character.
    > |
    > | Bob
    >
    > Guys,
    >
    > I know about the -n \c flags for echo... but no where and no time
    > did I ever imagine what you so clearly explain above.
    >
    > Where I typically use 'wc' is if I run a classified or to rent some
    > commercial space, or sell something, or hire someone. I use(d) the
    > 'wc' command to determine the cost of the ad by the character count.
    > I never would have detected it except I tried it on one word.
    >
    > Looks like I've been getting "Oa'ed" for some time.
    > Bobby... does this mean I'm "going" or "staying" nuts? :-)


    It's worse. The handling of end-of-line is OS specific. It's 'linefeed' for
    UNIX and Linux, 'carriage return + linefeed' for Windows, and 'carriage
    return' for Mac and some other systems.

    Don't get me going on what VMS did, but if you measure character counts by
    file length, it can get a bit nutty.

  7. Re: wc anomaly

    Jeff Hyman wrote (on Sun, Mar 30, 2008 at 11:43:34AM -0400):

    | Bob Stockler typed (on Sat, Mar 29, 2008 at 03:53:42PM -0400):
    | | Jeff Hyman wrote (on Sat, Mar 29, 2008 at 03:16:23PM -0400):
    | |
    | | | # echo "abcde" > /tmp/foo
    | | | # wc -m /tmp/foo (-c flag gives same results)
    | | | 6 foo
    | | |
    | | | Am I going nuts, or is this a bug?
    | |
    | | You're going (or staying) nuts.
    | |
    | | | File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    | | |
    | | | If this is the way it's supposed to be, then
    | | | how can one rely on its output except to remember
    | | | to subtract 1 ?
    | |
    | | If you execute:
    | |
    | | hd /tmp/foo
    | |
    | | you'll see there are 6 characters in it - "abcde" followed by "0a",
    | | the newline character.
    | |
    | | Bob
    |
    | Guys,
    |
    | I know about the -n \c flags for echo... but no where and no time
    | did I ever imagine what you so clearly explain above.
    |
    | Where I typically use 'wc' is if I run a classified or to rent some
    | commercial space, or sell something, or hire someone. I use(d) the
    | 'wc' command to determine the cost of the ad by the character count.
    | I never would have detected it except I tried it on one word.
    |
    | Looks like I've been getting "Oa'ed" for some time.
    | Bobby... does this mean I'm "going" or "staying" nuts? :-)

    Staying.

    Bob

    --
    Bob Stockler +-+ bob@trebor.iglou.com +-+ http://members.iglou.com/trebor

  8. Re: wc anomaly

    Bob Stockler wrote:

    > Jeff Hyman wrote (on Sun, Mar 30, 2008 at 11:43:34AM -0400):
    >
    > | Bob Stockler typed (on Sat, Mar 29, 2008 at 03:53:42PM -0400):
    > | | Jeff Hyman wrote (on Sat, Mar 29, 2008 at 03:16:23PM -0400):
    > | |
    > | | | # echo "abcde" > /tmp/foo
    > | | | # wc -m /tmp/foo (-c flag gives same results)
    > | | | 6 foo
    > | | |
    > | | | Am I going nuts, or is this a bug?
    > | |
    > | | You're going (or staying) nuts.
    > | |
    > | | | File 'foo' has 5 characters, not 6 ... and no blank lines or spaces.
    > | | |
    > | | | If this is the way it's supposed to be, then
    > | | | how can one rely on its output except to remember
    > | | | to subtract 1 ?
    > | |
    > | | If you execute:
    > | |
    > | | hd /tmp/foo
    > | |
    > | | you'll see there are 6 characters in it - "abcde" followed by "0a",
    > | | the newline character.
    > | |
    > | | Bob
    > |
    > | Guys,
    > |
    > | I know about the -n \c flags for echo... but no where and no time
    > | did I ever imagine what you so clearly explain above.
    > |
    > | Where I typically use 'wc' is if I run a classified or to rent some
    > | commercial space, or sell something, or hire someone. I use(d) the
    > | 'wc' command to determine the cost of the ad by the character count.
    > | I never would have detected it except I tried it on one word.
    > |
    > | Looks like I've been getting "Oa'ed" for some time.
    > | Bobby... does this mean I'm "going" or "staying" nuts? :-)
    >
    > Staying.
    >
    > Bob
    >


    Nuts is nuts. The past doesn't matter, only the present
    and the future.

+ Reply to Thread