thanks oombera. I might use this but I'm helping a friend write a script for an Inro. to Unix class and the class doesnt cover the awk command. Could you list any other ways that you know?
Just as a sidenote, I thought of wc first, but when I used it, it returned one greater than the number of characters in each string it tested, so that "hello" would return "6"... is it counting some end-of-line character?
to tell you the truth i am unsure what the 6th byte is. never noticed it before.
the only thing i can think of is this snipit from the environ(5) man page.
anyone else have any insite into why wc counts more 1 more charicter or byte then is in the file?
LC_CTYPE
This category specifies character classifica-
tion, character conversion, and widths of multi-
byte characters. When LC_CTYPE is set to a
valid value, the calling utility can display and
handle text and file names containing valid
characters for that locale; Extended Unix Code
(EUC) characters where any individual character
can be 1, 2, or 3 bytes wide; and EUC characters
of 1, 2, or 3 column widths. The default "C"
locale corresponds to the 7-bit ASCII character
set; only characters from ISO 8859-1 are valid.
The information corresponding to this category
is stored in a database created by the
localedef() command. This environment variable
is used by ctype(3C), mblen(3C), and many com-
mands, such as cat(1), ed(1), ls(1), and vi(1).
but also when i put hello in a text file useing vi i also get 6 char.
that octal dump program looks interesting. will deffinetly check out that man page.
Okay, that's understandable, Ygor. From the man page for echo:
From the man page for wc:
So basically, the newline character is there and wc has no way of suppressing it itself, so it must be suppressed with printf, echo -n, or something similar...