[LA.pm] Perl END question - STDIN end of file?

Peter Benjamin pete at peterbenjamin.com
Wed Jan 18 13:27:49 PST 2006


I'd like to have a command that tells me the true hard drive
space usage for sparse files.  The problem with the below
command is that the STDIN to perl is not terminate, so
the END statement never executes, until the enter key
is pressed again.  What is up with this?  How do I tell
END when to start?  Is this a problem with backtics?
Using du `...` >n ; cat n | perl ...   will work fine.
So, I suspect it has to do with the end of file marker
that cat has, but that the pipe might be missing.

du `file * | grep 'ext2' | sed -e 's/^\([^:]*\).*$/\1/'` | perl -n -e 'END{ print "$t\n"} print;chomp;s/[ \t].*$//;$t=$t+$_'

Yes, I could put all the commands into perl, but I want a shell script.
Something I can iterate to do more from the command line.

--

Background:
The LA UML Coop, <http://docs.lauml.com/>, has 10 gig UML filesystems
that are sparse, taking up somewhat less than 10 gig as shown by
the ls command.  The du command shows the real space used.

The need is for the total space used for filesystem files of type ext2,
and perhaps other types, but ext2 is fine for now, within the current
working directory.



More information about the Losangeles-pm mailing list