rajeshkumar created the topic: convert df -h output to html table
Code shared on permonks by choroba.
#!/usr/bin/perl
use warnings;
use strict;
use Text::Table;
use constant CAPACITY => 3;
my @lines = `df -hP`;
my $header = shift @lines;
# Do not create two columns for "Mounted" and "On"
$header =~ s/Mounted /Mounted_/;
my $table = Text::Table->new(split ' ', $header);
{
no warnings 'numeric'; # Ignore % signs
@lines = sort { $a->[CAPACITY] <=> $b->[CAPACITY] }
map [split ' ', $_], @lines;
}
$table->load(@lines);
print $table;
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn
rajeshkumar replied the topic: Re: convert df -h output to html table
There is one i made it working as below;
#############################################
#!/usr/local/bin/perl
# Use either -h or -k flag or leave it blank for default (-k)
# -h for human-readable size output
# -k for 1k-block output
$flag = "-h";
@df = `df $flag`;
print "Content-type: text/htmln\n";
print "
Filesystem | Size | 1k-blocks | Used | Avail | Capacity | Mounted on |
$fsystem | $blocks | $used | $avail | $capacity | $mounted |
\n";
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND