if i do the following:
echo "hello, mr. sunshine" > /tmp/text.txt
du -s /tmp/text.txt
The text.txt file now contains "hello, mr. sunshine". So i did a du -s on the file to see how much space the text i inserted took.
now, instead of writing "hello, mr. sunshine" to a text file on the disk, i'd like to save it to a variable and calculate how much space it would take on disk without having to write to disk.
So, something along the lines of:
VAR="hello, mr. sunshine"
du -s $VAR (this wont work of course, since the content of a $VAR is not a actual file).
Is what i'm asking possible?
I'm running Red Hat 6 and Sun 5.10 and i'm using bash.