The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
iptables assistance beaker457 IP Networking 1 02-12-2009 05:03 PM
How is use sselect statement o/p in insert statement. nkosaraju Shell Programming and Scripting 2 08-06-2008 10:26 PM
If statement - How to write a null statement april Shell Programming and Scripting 3 04-16-2008 02:14 PM
I need an assistance mytilini boy Shell Programming and Scripting 1 05-25-2007 09:42 PM
Need Assistance yahoo14 UNIX for Dummies Questions & Answers 1 06-08-2006 11:21 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-27-2009
rkruck rkruck is offline
Registered User
  
 

Join Date: Aug 2008
Location: Sterling, VA
Posts: 20
AWK statement formatting assistance

I am writing a script that ssh's out to our various servers and extracts diskspace info to generate into a report. With the mix of servers linux/solairs 8-10/AIX the easiest way is to use df -k (though I much rather prefer df -h).

I have pasted the relevant code:


Code:
dfdata=`ssh -q -o ConnectTimeout=10 rkruck@$host df -k `
           if (( $? == 0 ))
           then
                echo "$dfdata" | \
                     grep "/dev/" | \
                     egrep ' 9[0-9]%| 100%' | \
                     awk '{printf "%-16s        %4s             %6.2f        %s\n"
, H, $5, $4/ 1024, $6}' H=$host  >> $RDIR/diskspace.$RDATE

I get the right output, but am having trouble formatting the 3rd colum lining up so it's right justfied with the 2 decimal places lining up so it looks like the following:


Code:
hostname1                      91%               1809.53            /u01
hostname2                      95%               1196.00            /u02
hostname3                      99%               209.20            /u04
hostname4                      97%               734.77             /u03
hostname5                      98%               448.74            /u08
hostname6                      94%               1214.33            /u07
hostname7                     100%               188.25            /u05
hostname8                      95%               1053.51            /u09
hostname9                      94%               4232.70            /d02
hostname10                     91%               6424.62            /d01
hostname11                     99%               24354.89            /ora05
hostname12                     90%               643.86            /home

Any help is appreicated.

Robert

Last edited by rkruck; 08-27-2009 at 04:53 PM.. Reason: fixed formatting from code tags
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0