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 |