Link to home
Start Free TrialLog in
Avatar of dfn48
dfn48

asked on

Disk Ram Peak

OS is AIX

My code works but I am having one problem. When the results output to the screen, the column headers and data are not aligned correctly.  How can this be corrected in the code so that the column headers align with the data?

Please see attachments


Here is the code
!/bin/ksh
 
 
 
fpath=/sas/scripts/OPTUMize/output/disk_utilization
 
# get input
echo "Enter Group name: "
read gname
 
echo "Enter Current Date: "
read cdate
# format: 09/30/2016
 
# parse date
yyyy=$(echo ${cdate} | cut -d"/" -f3)
dd=$(echo ${cdate} | cut -d"/" -f2)
mm=$(echo ${cdate} | cut -d"/" -f1)
 
echo "Enter number of records: "
read nrec
 
# construct file name to parse
diskfile=${fpath}/disk_${yyyy}.${mm}.${dd}.txt
 
# check if file exists
if [ ! -f ${diskfile} ]
then
                echo File: ${diskfile} not found. Exiting.
                exit 1
fi
 
# generate output on screen - TAB separated (OFS)
awk -v gname=${gname} -v OFS="\t" 'BEGIN { print "Filesystem", "blocks", "Free", "% Used", "%Iused", "Mounted on", "Date", "Time" }
$0 ~ gname { gsub(/_/,""'"OFS"'"",$7); print $1, $2, $3, $4, $5, $6, $7 }' ${diskfile} | head -$(expr ${nrec} + 1)
 

Open in new window

disk_2016.11.29.txt
data-not-aligned-with-column-headers.txt
how-i-want-results.txt
ASKER CERTIFIED SOLUTION
Avatar of Gerald Connolly
Gerald Connolly
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial