@sam@: Can you be more specific about what it is you are after?
You talk about the size of a string and using du to determine this. du reports the size of a file, normally reported in the amount of blocks needed for disk storage.
Using your string1 as an example, du will show:
Code:
$ du test.file
4 test.file
This tells you that 4.0k is needed to store this file on disk. This reported size will stay the same if you add a few characters to the string (up to a point, after which the size will become 8.0k)
The actual file itself isn't 4.0k:
Code:
$ du -b test.file
80 test.file
# or using stat:
$ stat test.file
File: `test.file'
Size: 80 Blocks: 8 IO Block: 4096 regular file
80 bytes are needed.
The length of the string itself is 79 characters("bytes") the extra byte is the carriage return, which is part of the file and not the string itself.
So, what is it you are actually trying to determine?