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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
More than transposing! bulash UNIX Desktop for Dummies Questions & Answers 3 04-11-2008 02:20 PM
Transposing string unibboy Shell Programming and Scripting 3 02-13-2008 02:12 PM
Another transposing issue stevesmith Shell Programming and Scripting 14 09-16-2006 01:48 AM
file transposing mskcc Shell Programming and Scripting 24 08-04-2005 08:23 AM
transposing letters myscsa2004 Shell Programming and Scripting 4 05-12-2004 07:11 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-04-2005
Registered User
 

Join Date: May 2005
Posts: 1
Major Awk problems (Searching, If statements, transposing etc.)

Please bare with me as task is very detailed and I'm extremely new to Awk/sed. Keep in mind I'm running windows so I'm using a dos prompt

The attachment is a server report that I'm trying to manipulate with little success. For each server, I need to take the most recent information about them and then have them put into a file. After I have the most recent information, I have to transpose my rows into columns so instead of:

System Availability 100.00%
Total Uptime 551d 8h 12m 23s
Total Downtime 0d 0h 24m 51s
Total Reboots 11
Mean Time Between Reboots 50.12 days
Total Bluescreens 0

I would get:
System Availability Total Uptime Total Downtime
100.00% 551d 8h 12m 23 s 0d 0h 24m 51s

the rest of the rows would be included also.

However, some of the servers have two different sets of information and I need the most recent. Also, some of the servers do not display all of the information so I need still need those rows to be aligned in the proper columns.

I've been working on this for awhile so any help will be greatly appreciate.

Thanks
Attached Files
File Type: txt Server.txt (18.1 KB, 12 views)
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-04-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,226
This uses a few arrays...
Code:
$1 == "**********************"  {
        getline
        sv = $1   
        su[sv] = tu[sv] = td[sv] = "-"    
        getline
}

/System Availability/   { 
        sa[sv] = $3    
}

/Total Uptime/  { 
        tu[sv] = $3 " " $4 " " $5 " " $6
}

/Total Downtime/        { 
        td[sv] = $3 " " $4 " " $5 " " $6
}

END {
        fmt = "%-15s%20s%20s%20s\n"
        printf fmt, "Server", "System Availability", "Total Uptime", "Total Downtime"
        for (sv in sa) {
                printf fmt, sv, sa[sv], tu[sv], td[sv]
        }
}
Tested on the sample file...
Code:
Server          System Availability        Total Uptime      Total Downtime
saturn2                      99.99%     95d 18h 16m 53s       0d 0h 18m 31s
dione                        99.79%    1044d 2h 32m 56s       2d 3h 47m 19s
portia                      100.00%     36d 23h 33m 19s         0d 0h 2m 9s
mercury                      99.99%      77d 19h 31m 5s        0d 0h 6m 39s
:
Reply With Quote
  #3 (permalink)  
Old 09-05-2007
Registered User
 

Join Date: Sep 2007
Posts: 1
what about a file to be transposed with something like:

System Availability 100.00%
Total Uptime 551d 8h 12m 23s
Total Downtime 0d 0h 24m 51s
Total Reboots 11
Mean Time Between Reboots 50.12 days
Total Bluescreens 0


System Availability 100.00%
Total Uptime 534d 7h 1m 12s
Total Downtime 0d 0h 24m 51s
Total Reboots 11
Mean Time Between Reboots 50.12 days
Total Bluescreens 0


so the System Availability, Total Uptime etc is output once at the top of the column and just the information is extracted after that e.g.

System Availability Total Uptime Total Downtime ......
100.00% 551d 8h 12m 23s 0d 0h 24m 51s ......
100.00% 534d 7h 1m 12s 0d 0h 24m 51s .......
........
........

I'm really new to this so it would be great if you could help me out thanks.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0