Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:43:36+00:00 2026-06-02T23:43:36+00:00

Given the following command and its output: ssh -q $server ‘df -hP /raj* Size

  • 0

Given the following command and its output:

ssh -q $server 'df -hP /raj*

Size   Used  Avail Capacity  Mounted On
200G  154G   44G  79% /raj_day
200G  154G   44G  49% /raj1_day
200G  154G   44G  39% /raj2_day

I would like to convert into Tabular format so presentation should be good. Also, want to display Capacity in sorting order. Any tips for me in perl?

My Script as follows…

#############################################
#!/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 "<table border=2>\n";
print "<tr>\n";

print "<td><b>Filesystem</b></td>\n";

if ($flag eq "-h") {
    print "<td><b>Size</b></td>\n";
}
else {
    print "<td><b>1k-blocks</b></td>\n";
}

print "<td><b>Used</b></td>\n";
print "<td><b>Avail</b></td>\n";
print "<td><b>Capacity</b></td>\n";
print "<td><b>Mounted on</b></td>\n";
print "</tr>\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 "<tr bgcolor=green>\n";
}
elsif (($number >= 60) && ($number < 90)) {
    print "<tr bgcolor=yellow>\n";
}
else {
    print "<tr bgcolor=red>\n";
}
#
print "<td>$fsystem</td>\n";
print "<td>$blocks</td>\n";
print "<td>$used</td>\n";
print "<td>$avail</td>\n";
print "<td>$capacity</td>\n";
print "<td>$mounted</td>\n";
print "</tr>\n";
}

print "</table>\n";

OUTPUT AS FOLLOWS

Content-type: text/htmln
Filesystem Size Used
Avail Capacity Mounted
on
fsystem is /dev/ blocks is da3 95G
33G 58G 36% /

used is avail is capacity is mounted is fsystem is tmpf blocks is
499M 88K 499M 1% /dev/ used is hm

avail is capacity is mounted is fsystem is /dev/ blocks is da1
124M 39M 79M 33% /boot

used is avail is capacity is mounted is

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:43:38+00:00Added an answer on June 2, 2026 at 11:43 pm

    Like daxim already pointed out: It’s a stupid idea to parse the output of df, but if I had to hack down a small script it would probably look like this:

    df -B M -P /path1 /path2 /path3 | sed -e '1d' | sort -k 4,4 -r -h | column -t

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following command, echo "1: " | awk '/1/ -F ":" {print $1}'
Given a file with the following contents: <root> <a></a> <b></b> </root> The command should
The following command gives many manuals of Zsh man zsh<tab> alt text http://dl.getdropbox.com/u/175564/zsh.png I
I´m executing the following command grep bruno < bash.txt which gives me the right
Why gives the following Windows 7 .cmd command script: set SUN_JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_17 if
when i give the command rails s following error comes please help me! still
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
Given the following table: id category_id categorizable_id categorizable_type 66 22 67 Image 72 22

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.