in reply to couple of file content manipulation questions
use strict; use Filesys::Df; my $fobj = df("/"); print commify($fobj->{bavail} * 1024) . " bytes of " . commify($fobj->{blocks} * 1024) . " bytes free\n"; sub commify { my $text = reverse $_[0]; $text =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; }
That being said, I hope you're using open() or system() in list-mode, and not using backticks to get this info, if you're not using one of these modules. Something like:
use strict; my $fs = join(' ', @_); open(DF, "df $filesystems |"); my @df = <DF>; close(DF); chomp(@df);
|
|---|