Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
    Bumped by Community user
3 deleted 11 characters in body; edited tags; edited title
source | link

df -h command output in htmlHTML format with specific columns

I am trying to write a shell script which sends the output of df-hdf -h in mail with the help of htmlHTML code embedded in the script. The issue is this is printing all six columns. I only want only specific sequence ( 66,2,3,4,5). How do I achieve it.Tried? Tried lots of things putting array also ) but still not working. Pls help.

#! /bin/bash

MailTO=xyz@gmail.com
HOST=`hostname`
Numberofdays=2

ALERT_DIR_COUNT=`df -Ph | grep -v "Use%" | sed 's/%//g' | awk '$5 > 70 
{print $1,$2,$3,$4,$5"%",$6;}' | column -t | wc -l`

(
printf "To: xyz@gmail.com\n"
printf "Subject:$HOST\n :$ALERT_DIR_COUNT\n mounts reached threshold & Logs 
Cleared : $Numberofdays days\n"
printf "Content-Type: text/html\n"

printf "<html>\n
<body>\n"
df -Ph| awk '{ print $6,$2,$3,$4,$5 }''
BEGIN {
print "<table  border=\"8\" cellpadding=\"3\"  style=\"border-collapse: 
collapse\">"
printf "<tr>"
printf "<th bgcolor=turquoise colspan="6">BEFORE_USAGE</th>"
printf "</tr>"
printf "<tr>"
printf "<th bgcolor=gray>MOUNT</th>"
printf "<th bgcolor=gray>SIZE</th>"
printf "<th bgcolor=gray>USED</th>"
printf "<th bgcolor=gray>AVAILABLE</th>"
printf "<th bgcolor=gray>USE%</th>"

printf "</tr>"}
NR>1{
for( i = 1; i <= NF; i++ ) {
  printf "%s", "<td bgcolor=azure"
  if (i==5&&$i+0>70) printf " bgcolor=azure"
  print ">" $i "</td>"
 }
print "</tr>"
 }
END { print "</table>" }'

df -h command output in html format with specific columns

I am trying to write a shell script which sends the output of df-h in mail with the help of html code embedded in the script. The issue is this is printing all six columns. I only want specific sequence ( 6,2,3,4,5). How do I achieve it.Tried lots of things putting array also ) but still not working. Pls help.

#! /bin/bash

MailTO=xyz@gmail.com
HOST=`hostname`
Numberofdays=2

ALERT_DIR_COUNT=`df -Ph | grep -v "Use%" | sed 's/%//g' | awk '$5 > 70 
{print $1,$2,$3,$4,$5"%",$6;}' | column -t | wc -l`

(
printf "To: xyz@gmail.com\n"
printf "Subject:$HOST\n :$ALERT_DIR_COUNT\n mounts reached threshold & Logs 
Cleared : $Numberofdays days\n"
printf "Content-Type: text/html\n"

printf "<html>\n
<body>\n"
df -Ph| awk '{ print $6,$2,$3,$4,$5 }''
BEGIN {
print "<table  border=\"8\" cellpadding=\"3\"  style=\"border-collapse: 
collapse\">"
printf "<tr>"
printf "<th bgcolor=turquoise colspan="6">BEFORE_USAGE</th>"
printf "</tr>"
printf "<tr>"
printf "<th bgcolor=gray>MOUNT</th>"
printf "<th bgcolor=gray>SIZE</th>"
printf "<th bgcolor=gray>USED</th>"
printf "<th bgcolor=gray>AVAILABLE</th>"
printf "<th bgcolor=gray>USE%</th>"

printf "</tr>"}
NR>1{
for( i = 1; i <= NF; i++ ) {
  printf "%s", "<td bgcolor=azure"
  if (i==5&&$i+0>70) printf " bgcolor=azure"
  print ">" $i "</td>"
 }
print "</tr>"
 }
END { print "</table>" }'

df -h command output in HTML format with specific columns

I am trying to write a shell script which sends the output of df -h in mail with the help of HTML code embedded in the script. The issue is this is printing all six columns. I want only specific sequence (6,2,3,4,5). How do I achieve it? Tried lots of things putting array also ) but still not working.

#! /bin/bash

MailTO=xyz@gmail.com
HOST=`hostname`
Numberofdays=2

ALERT_DIR_COUNT=`df -Ph | grep -v "Use%" | sed 's/%//g' | awk '$5 > 70 
{print $1,$2,$3,$4,$5"%",$6;}' | column -t | wc -l`

(
printf "To: xyz@gmail.com\n"
printf "Subject:$HOST\n :$ALERT_DIR_COUNT\n mounts reached threshold & Logs 
Cleared : $Numberofdays days\n"
printf "Content-Type: text/html\n"

printf "<html>\n
<body>\n"
df -Ph| awk '{ print $6,$2,$3,$4,$5 }''
BEGIN {
print "<table  border=\"8\" cellpadding=\"3\"  style=\"border-collapse: 
collapse\">"
printf "<tr>"
printf "<th bgcolor=turquoise colspan="6">BEFORE_USAGE</th>"
printf "</tr>"
printf "<tr>"
printf "<th bgcolor=gray>MOUNT</th>"
printf "<th bgcolor=gray>SIZE</th>"
printf "<th bgcolor=gray>USED</th>"
printf "<th bgcolor=gray>AVAILABLE</th>"
printf "<th bgcolor=gray>USE%</th>"

printf "</tr>"}
NR>1{
for( i = 1; i <= NF; i++ ) {
  printf "%s", "<td bgcolor=azure"
  if (i==5&&$i+0>70) printf " bgcolor=azure"
  print ">" $i "</td>"
 }
print "</tr>"
 }
END { print "</table>" }'
2 edited tags
| link
1
source | link

df -h command output in html format with specific columns

I am trying to write a shell script which sends the output of df-h in mail with the help of html code embedded in the script. The issue is this is printing all six columns. I only want specific sequence ( 6,2,3,4,5). How do I achieve it.Tried lots of things putting array also ) but still not working. Pls help.

#! /bin/bash

MailTO=xyz@gmail.com
HOST=`hostname`
Numberofdays=2

ALERT_DIR_COUNT=`df -Ph | grep -v "Use%" | sed 's/%//g' | awk '$5 > 70 
{print $1,$2,$3,$4,$5"%",$6;}' | column -t | wc -l`

(
printf "To: xyz@gmail.com\n"
printf "Subject:$HOST\n :$ALERT_DIR_COUNT\n mounts reached threshold & Logs 
Cleared : $Numberofdays days\n"
printf "Content-Type: text/html\n"

printf "<html>\n
<body>\n"
df -Ph| awk '{ print $6,$2,$3,$4,$5 }''
BEGIN {
print "<table  border=\"8\" cellpadding=\"3\"  style=\"border-collapse: 
collapse\">"
printf "<tr>"
printf "<th bgcolor=turquoise colspan="6">BEFORE_USAGE</th>"
printf "</tr>"
printf "<tr>"
printf "<th bgcolor=gray>MOUNT</th>"
printf "<th bgcolor=gray>SIZE</th>"
printf "<th bgcolor=gray>USED</th>"
printf "<th bgcolor=gray>AVAILABLE</th>"
printf "<th bgcolor=gray>USE%</th>"

printf "</tr>"}
NR>1{
for( i = 1; i <= NF; i++ ) {
  printf "%s", "<td bgcolor=azure"
  if (i==5&&$i+0>70) printf " bgcolor=azure"
  print ">" $i "</td>"
 }
print "</tr>"
 }
END { print "</table>" }'