Thread: wc anomaly
View Single Post

   
  #3 (permalink)  
Old 04-03-2008, 03:45 PM
Bob Stockler
 
Posts: n/a
Default 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
Reply With Quote