Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Convert df -h output to html table

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 "

\n";
print "

\n";

print "

\n";

if ($flag eq "-h") {
print "

\n";
}
else {
print "

\n";
}

print "

\n";
print "

\n";
print "

\n";
print "

\n";
print "

\n";

foreach $line (@df) {
next if ($line =~ /Filesystem/);

($fsystem,$blocks,$used,$avail,$capacity,$mounted) = split(/\s+/,$line);

print "fsystem is $fsystem\n";
print "blocks is $blocks\n";
print "used is $used\n";
print "avail is $avail\n";
print "capacity is $capacity\n";
print "mounted is $mounted\n";

($number,$sign) = split(/%/,$capacity);
if ($number < 60) { print "

\n";
}
elsif (($number >= 60) && ($number < 90)) { print " \n";
}
else {
print "

\n";
}
#
print "

\n";
print "

\n";
print "

\n";
print "

\n";
print "

\n";
print "

\n";
print "

\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

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

What is Perl and use cases of Perl?

What is Perl? Perl is a high-level, general-purpose programming language known for its flexibility, ease of use, and powerful text manipulation capabilities. Originally developed by Larry Wall…

Read More

What is Perl and How it works? An Overview and Its Use Cases

Hey, this is Ashwani, and in this article I’m going to share some important things about Perl. As you see in the heading everything is clear to…

Read More

Introdcution of Perl

What is Perl Perl is a programming language, It’s Object Oriented, simple to learn and very powerful. Perl stand for: “Practical Extraction and Reporting Language”. Perl is…

Read More

Remove Control ^M from files

tpatil created the topic: Remove Control ^M from files Single file method perl -pi -e “s/\r//” filename.txt Multiple File Method find . -type f -exec perl -pi…

Read More

I need to a perl script

rajeshkumar created the topic: i need to a perl script Hi , There is a file called test.txt what are all the different ways BEGIN: test 1…

Read More

The difference between my and local

rajeshkumar created the topic: The difference between my and local There is a subtle difference. In the example below, $::a refers to $a in the ‘global’ namespace….

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x