Output top line for each unique host

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Output top line for each unique host
# 8  
Old 02-28-2017
That is perfect thanks
# 9  
Old 03-16-2017
Hi All,
I am using this command "bpdbjobs -most_columns | awk '!a[$3]++'"

But I noticed a slight issue.

I need to look at column $3 and $8 and if the entries are the same, then I should take the first (top) line..

I hope I have explained this correctly. Look at "sv204134" - second and third line below

If a job is still running, then command above "awk '!a[$3]++'"" is outputting job completed line - 243285912 and job still running - 243286673 and I want it to only display job still running - 243286673 and ignore (not show) job completed.

So I need to compare $3 and $8


Code:
# bpdbjobs -most_columns | sed -e "s/\,/ /g"  | awk '{ if($2=="0") print $0}' | grep -i sv20413 | awk '{print $1,$3,$7,$5,$9,$(10),$13,$6,$4}' | awk '!a[$3]++'

243286674 3 sv204135 LDN_CAM_NT_PRD_VMWARE_SQL 1489629600 0000000324 1 INC_1MTH 1
 **** 243286673 1 nbnesln1p02 INC_1MTH 0000023162 0000000000 3 sv204134 LDN_WAT_NT_PRD_VMWARE_SQL                    (Job Running - should be reported)
243286157 3 sv204133 LDN_WAT_NT_PRD_VMWARE 1489604401 0000000707 1 INC_1MTH 1
***** 243285912 3 sv204134 LDN_WAT_NT_PRD_VMWARE_SQL 1489543200 0000029480 1 INC_1MTH 1                           (Job Completed - should not be reported)

Please can you help....

Thanks

Last edited by Junes; 03-16-2017 at 06:11 AM..
# 10  
Old 03-16-2017
I'm afraid I don't see your point. Why should a job being completed output a "still running" line?

Without seeing a sample of the input, it will be difficult if not impossible to analyse the problem and propose a solution.
# 11  
Old 03-16-2017
These are backup jobs... The report keeps last 3 days worth of data. Hence when I run the tool commands "bpdbjobs -most_columns ", it shows more than one day of output.

Code:
bpdbjobs -most_columns | awk '!a[$3]++'

The following command works fine, but if a job has completed (provides the unique of column 3).

The script output is correct, because $3 for line output 2 and 4 are unique. -

Code:
243286674 3 sv204135 LDN_CAM_NT_PRD_VMWARE_SQL 1489629600 0000000324 1 INC_1MTH 1
 **** 243286673 1 nbnesln1p02 INC_1MTH 0000023162 0000000000 3 sv204134 LDN_WAT_NT_PRD_VMWARE_SQL                    (Job Running - should be reported)
243286157 3 sv204133 LDN_WAT_NT_PRD_VMWARE 1489604401 0000000707 1 INC_1MTH 1
***** 243285912 3 sv204134 LDN_WAT_NT_PRD_VMWARE_SQL 1489543200 0000029480 1 INC_1MTH 1                           (Job Completed - should not be reported)


I need to perform a comparison $3 and $8, which give the same string and it will choose the line, which in $8.

I hope this make more sense

---------- Post updated at 12:49 PM ---------- Previous update was at 10:23 AM ----------

I found a different way to get the output, at the end of the script. Using the following command for the output

Code:
awk '!a[$2]++'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

Sorting out unique values from output of for loop.

Hi , i have a belwo script which is used to get sectors per track value extarcted from Solaris machine: for DISK in /dev/dsk/c*t*d*s*; do value=`prtvtoc "$DISK" | sed -n -e '/Dimensions/,/Flags/{/Dimensions/d; /Flags/d; p; }' | sed -n -e '/sectors\/track/p'`; if ; then echo... (4 Replies)
Discussion started by: omkar.jadhav
4 Replies

3. Solaris

Host name in front of ps output

hello All. I am working on something that should be really simply. It turns out that its not. I am trying to produce output to list the hostname along with all the current running programs. the script im using is: for PS in `ps -Ao "user,args" | cut -d' ' -f1,2` do echo "`uname -n`, $PS"... (5 Replies)
Discussion started by: busi386
5 Replies

4. Shell Programming and Scripting

Output first unique record in csv file

Hi, I have to output a new csv file from an input csv file with first unique value in the first column. input csv file color product id status green 102 pass yellow 201 hold yellow 202 keep green 101 ok green 103 hold yellow 203 ... (5 Replies)
Discussion started by: Chris LAU
5 Replies

5. Shell Programming and Scripting

How to get unique of file1 from file2 and save the output?

Please help, file1.txt 1 2 3 4 5 file2.txt 3 4 5 6 7 All I need is this result.txt 1 2 (17 Replies)
Discussion started by: richmac
17 Replies

6. Shell Programming and Scripting

grep with date & unique output

alert.log has the entries with ORA-XXXX, .... Mon Sep 24 15:08:09 2012 WARNING: inbound connection timed out (ORA-3136) Mon Sep 24 15:08:09 2012 WARNING: inbound connection timed out (ORA-3136) Mon Sep 24 15:08:09 2012 WARNING: inbound connection timed out (ORA-3136) Mon Sep 24 15:15:01... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

7. Solaris

top output and swap -s output are differing

Solaris experts, Am struggling, and wondering for the past more than one week that, how to calculate the total available and used memory/swap space. Finally installed and used top & got some understanding, but while cross-checking, there are mismatches. Main Memory top o/p - 2GB... (7 Replies)
Discussion started by: thegeek
7 Replies

8. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

9. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

10. UNIX for Advanced & Expert Users

top output

Hi all, below is the output of my 'top' Tasks: 91 total, 2 running, 89 sleeping, 0 stopped, 0 zombie Cpu(s): 3.9% us, 20.5% sy, 0.0% ni, 75.6% id, 0.0% wa, 0.0% hi, 0.0% si Can someone tell me what does us, sy,ni,id,wa,hi,si stands stand for? (4 Replies)
Discussion started by: new2ss
4 Replies
Login or Register to Ask a Question