04-25-2008
Displaying Output in Columns
I'm writing a script to analyze the logs of an smtp relay machine and I'd like the final output to be displayed in columns showing results from the previous day, week, month, and 45 days. The problem I'm running into is that I can't figure out how to display the columns neatly so there is no staggering.
This is similar to what I end up with:
_______________________________________________
Daily Weekly Monthy
_______________________________________________
1). 234 domain 1). 435 domain 1). 4576 domain
2). 12 domain 2). 23 domain 2). 34 domain
3). 2 domian 3). 3 domain 3). domain
Even when I use tabs between the parameters, not all the columns line up nicely.
Anyway, here's how I got this far:
After getting all the lines from the logs, I got the domain name from each line, sorted the names, counted the duplicate lines, and put the top results from each given time period into a file with the lines numbered. The file looks something like this:
1). DailyResults 346 domainName
2). DailyResults 243 domainName
3). DailyResults 123 domainName
1). WeeklyResults 345 domainName
2). WeeklyResults 234 domainName
3). WeeklyResults 123 domainName
1). MonthlyResults 345 domainName
2). MonthlyResults 234 domainName
3). MonthlyResults 123 domainName
1). TotalResults 345 domainName
2). TotalResults 234 domainName
3). TotalResults 123 domainName
Then I used a command for each line to join the lines:
echo `cat list_of_domains|grep "1)."|awk '{print $1, $2 ,$4" "$5 ,$6, $8," "$9, $10, $12" "$13, $14, $16}'`
Which gives me this output:
1). 234 domain 1). 435 domain 1). 4576 domain
2). 12 domain 2). 23 domain 2). 34 domain
3). 2 domian 3). 3 domain 3). domain
(something like this trivial example would probably line up well by using tabs between the parameters, but of course, the domain names i'm working with vary in length much more)
At this point the script is pretty ugly and I'm willing to attack this problem from a different angle if anyone has any suggestions. Any help is greatly appreciated.
THANKS!
-JJ
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I've just finished my first script (about displaying open ports on the computer and who opened them) and everything is fine with it but I want to style it a little bit just for the sake of learning how to do this.
What I want to do is make the display like the one of ps, for example,... (6 Replies)
Discussion started by: sanchopansa
6 Replies
2. Shell Programming and Scripting
can i display range of columns in AWk...
say in cut command i can display columnm 2-13....
is there is any simmilar command in awk (1 Reply)
Discussion started by: mahabunta
1 Replies
3. Shell Programming and Scripting
i having problems figuring out how to 'read' in 3 different directory listings and then display them on the screen into 3 separate columns.
i thought i could use a 'for' loop to grab each directory and then assign a unique variable to each line 'read' in.
of course, as you experts all know,... (16 Replies)
Discussion started by: mjays
16 Replies
4. Shell Programming and Scripting
Hello all,
Code below:
echo "Oracle Filesystems"
echo "------------------"
echo
for j in `df -l -k |grep total|grep ora|grep -v storage|grep -v vg00|awk '{print $1}'`
do
echo $j is `df -l -k $j |grep total|grep ora|grep -v storage|grep -v vg00|awk -F":" '{print $2}'|awk '{print $1}'` KB... (6 Replies)
Discussion started by: LinuxRacr
6 Replies
5. UNIX for Dummies Questions & Answers
Hi, I'm just wondering how you display a specific set of columns of a specified file in Unix. For example, if you had an AddressBook file that stores the Names, Phone numbers, and Addresses of people the user entered in the following format (the numbers are just to give an idea of what column... (1 Reply)
Discussion started by: logorob
1 Replies
6. Shell Programming and Scripting
Hi all,
Below is my shell script that calls a stored procedure(with output parameter)
I have tried executing this script but it doesn't display the output parameter value. Can anyone help me ? :(
#!/bin/bash
###############################################################################... (7 Replies)
Discussion started by: saviochacko
7 Replies
7. Shell Programming and Scripting
Hello,
I have a huge file with many columns . I want to use the names of the columns to print columns to another file.
for example
file.txt
COLA COLB COLC COLD
1 2 3 5
3 5 6 9
If I give name for multiple columns to the code:... (5 Replies)
Discussion started by: ryan9011
5 Replies
8. Shell Programming and Scripting
Hi All,
I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form
1). Intercomponents Checking
Passed: All Server are passed.
======================================================================
2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies
9. Shell Programming and Scripting
I feel bad for posting so much lately. I've just been working on a project for fun to force myself to learn Python better. Recently I decided to incorporate this ping.py script on github found here. I'm not going to bore you with all the changes I made, but the problem now lies in this function... (8 Replies)
Discussion started by: Azrael
8 Replies
10. UNIX for Dummies Questions & Answers
Hi All,
I am new to shell scripting. I have a requirement as part of my job to find out null/empty values in column 2 and column 3 from a CSV file and exit the further execution of script by displaying a simple error message.
I have developed a script to do this by reading various articles... (7 Replies)
Discussion started by: tpk
7 Replies
LEARN ABOUT V7
asadmin-delete-domain
asadmin-delete-domain(1AS) User Commands asadmin-delete-domain(1AS)
NAME
asadmin-delete-domain, delete-domain - deletes the givendomain
SYNOPSIS
delete-domain [--terse=false] [--echo=false] [--domaindir install_dir/domains] domain_name
delete-domain deletes the specified domain. The domain must already exist and must be stopped. This command is supported in local mode
only.
OPTIONS
--domaindir directory where the domain is to be deleted. If specified, path must be accessible in the filesystem. If not speci-
fied, the domain in the default install_dir/domains directory is deleted.
--terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well-
formatted data for consumption by a script. Default is false.
--echo setting to true will echo the command line statement on the standard output. Default is false.
OPERANDS
domain_name name of the domain. Must be a unique name.
Example 1: Using delete-domain
asadmin> delete-domain sampleDomain
deleted domain sampleDomain successfully
Where: the sampleDomain domain is deleted.
EXIT STATUS
0 command executed successfully
1 error in executing the command
asadmin-create-domain(1AS), asadmin-start-domain(1AS), asadmin-stop-domain(1AS), asadmin-list-domains(1AS)
J2EE 1.4 SDK March 2004 asadmin-delete-domain(1AS)