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
# 1  
Old 02-28-2017
Output top line for each unique host

Hi All,
Please can you help with the output whole line for each host (column 3) and the top line of column 9 - the lastest only

What is being outputted

Code:
243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0    **********
243272492 3 nbmedln1p03 LDN_TEST_UX_JM 1488212022 0000000007 1 INC_1MTH 0
243272493 3 nbmedln1p03 LDN_TEST_UX_JM 1488212057 0000000008 1 INC_1MTH 150
243272489 3 nbmedln1p03 LDN_TEST_UX_JM2 1488209081 0000003026 1 INC_1MTH 157
243272494 3 nbmedln1p03 LDN_TEST_UX_JM2 1488212106 0000000531 2 INC_1MTH 150
243273284 3 nbmedln1p03 LDN_TEST_UX_JM3 1488276803 0000000012 1 FULL_1MTH 0
243273293 3 nbmedln1p03 LDN_TEST_UX_JM3 1488276804 0000000021 1 FULL_1MTH 0

Only require the top line.
Code:
243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0

I have tried the following commands, but getting the following oupput

Code:
bpdbjobs -most_columns | sed -e "s/\,/ /g"  | grep -i LDN_TEST_UX_JM  | awk '{print $1,$3,$7,$5,$9,$(10),$13,$6,$4}' | sort -k 3,9 -u
243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0
243272492 3 nbmedln1p03 LDN_TEST_UX_JM 1488212022 0000000007 1 INC_1MTH 0
243272493 3 nbmedln1p03 LDN_TEST_UX_JM 1488212057 0000000008 1 INC_1MTH 150
243272489 3 nbmedln1p03 LDN_TEST_UX_JM2 1488209081 0000003026 1 INC_1MTH 157
243272494 3 nbmedln1p03 LDN_TEST_UX_JM2 1488212106 0000000531 2 INC_1MTH 150
243273284 3 nbmedln1p03 LDN_TEST_UX_JM3 1488276803 0000000012 1 FULL_1MTH 0
243273293 3 nbmedln1p03 LDN_TEST_UX_JM3 1488276804 0000000021 1 FULL_1MTH 0

Code:
bpdbjobs -most_columns | sed -e "s/\,/ /g"  | grep -i LDN_TEST_UX_JM  | awk '{print $1,$3,$7,$5,$9,$(10),$13,$6,$4}' | sort -u -k3  | awk '!array[$4]++'
243273281 3 nbmedln1p01 LDN_TEST_UX_JM3 1488276803 0000000008 1 FULL_1MTH 0
243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0
243272489 3 nbmedln1p03 LDN_TEST_UX_JM2 1488209081 0000003026 1 INC_1MTH 157

Code:
bpdbjobs -most_columns | sed -e "s/\,/ /g"  | grep -i LDN_TEST_UX_JM  | awk '{print $1,$3,$7,$5,$9,$(10),$13,$6,$4}' | sort -u -k3  | awk '!array[$9]++' 

243273281 3 nbmedln1p01 LDN_TEST_UX_JM3 1488276803 0000000008 1 FULL_1MTH 0
243272493 3 nbmedln1p03 LDN_TEST_UX_JM 1488212057 0000000008 1 INC_1MTH 150
243272489 3 nbmedln1p03 LDN_TEST_UX_JM2 1488209081 0000003026 1 INC_1MTH 157

Any help will be appericated


Moderator's Comments:
Mod Comment Please use CODE tags correctly (not ICODE) as required by forum rules!

Last edited by RudiC; 02-28-2017 at 07:06 AM.. Reason: Changed CODE tags.
# 2  
Old 02-28-2017
Without the respective input data - (probably) the output of bpdbjobs -most_columns - it's diffcult to tell what would be the best approach.
# 3  
Old 02-28-2017
Is this just the job for the head command?


Robin
# 4  
Old 02-28-2017
Would this come close to what you need?
Code:
bpdbjobs -most_columns | sort -t, -uk7 | awk '/LDN_TEST_UX_JM/ {print $1,$3,$7,$5,$9,$10,$13,$6,$4; exit}' FS=,

# 5  
Old 02-28-2017
Sorry I should have been more clear. I am looking to get a particular output.

bpdbjobs -most_columns - Command out data from the data base (Netbackup Command)


Code:
bpdbjobs -most_columns | sed -e "s/\,/ /g"  | grep -i LDN_TEST_UX_JM  | awk '{print $1,$3,$7,$5,$9,$(10),$13,$6,$4}' | sort -k 3,9 -u

243273281 3 nbmedln1p01 LDN_TEST_UX_JM3 1488276803 0000000008 1 FULL_1MTH 0		*********
243273283 3 nbmedln1p02 LDN_TEST_UX_JM3 1488276803 0000000010 1 FULL_1MTH 0		*********
243273292 3 nbmedln1p02 LDN_TEST_UX_JM3 1488276804 0000000019 1 FULL_1MTH 0
243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0		*********
243272492 3 nbmedln1p03 LDN_TEST_UX_JM 1488212022 0000000007 1 INC_1MTH 0
243272493 3 nbmedln1p03 LDN_TEST_UX_JM 1488212057 0000000008 1 INC_1MTH 150
243272489 3 nbmedln1p03 LDN_TEST_UX_JM2 1488209081 0000003026 1 INC_1MTH 157
243272494 3 nbmedln1p03 LDN_TEST_UX_JM2 1488212106 0000000531 2 INC_1MTH 150
243273284 3 nbmedln1p03 LDN_TEST_UX_JM3 1488276803 0000000012 1 FULL_1MTH 0
243273293 3 nbmedln1p03 LDN_TEST_UX_JM3 1488276804 0000000021 1 FULL_1MTH 0
243273285 3 nbmedln1p04 LDN_TEST_UX_JM3 1488276803 0000000012 1 FULL_1MTH 0		*********
243273282 3 nmagbp01 LDN_TEST_UX_JM3 1488276803 0000000190 1 FULL_1MTH 150		*********
243273300 3 nmagbp01 LDN_TEST_UX_JM3 1488277592 0000000203 1 FULL_1MTH 0


I want the following output only, so column 3 is unique and column 9 is the last failure (column 9 is failure code.)

Code:
243273281 3 nbmedln1p01 LDN_TEST_UX_JM3 1488276803 0000000008 1 FULL_1MTH 0		*********
243273283 3 nbmedln1p02 LDN_TEST_UX_JM3 1488276803 0000000010 1 FULL_1MTH 0		*********
243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0		*********
243273285 3 nbmedln1p04 LDN_TEST_UX_JM3 1488276803 0000000012 1 FULL_1MTH 0		*********
243273282 3 nmagbp01 LDN_TEST_UX_JM3 1488276803 0000000190 1 FULL_1MTH 150		*********


Last edited by rbatte1; 02-28-2017 at 09:58 AM.. Reason: Changed ICODE tags to CODE tags
# 6  
Old 02-28-2017
See post#2.
# 7  
Old 02-28-2017
not sure if that's what you're after.....
Code:
bpdbjobs -most_columns | awk '!a[$3]++'

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