Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

🚗 You set the rental price
🔐 Secure bookings with verified renters
📍 Track your vehicle with GPS integration
💰 Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

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

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x