![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 03: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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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]
}
}
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 : |
|
#3
|
|||
|
|||
|
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. |
|||
| Google The UNIX and Linux Forums |