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

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.

243272484 3 nbmedln1p03 LDN_TEST_UX_JM 1488198368 0000000007 1 INC_1MTH 0

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

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

Without the respective input data - (probably) the output of bpdbjobs -most_columns - it's diffcult to tell what would be the best approach.

Is this just the job for the head command?

Robin

Would this come close to what you need?

bpdbjobs -most_columns | sort -t, -uk7 | awk '/LDN_TEST_UX_JM/ {print $1,$3,$7,$5,$9,$10,$13,$6,$4; exit}' FS=,

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)

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

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		*********


See post#2.

not sure if that's what you're after.....

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

That is perfect thanks

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

# 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

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.

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.

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

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

awk '!a[$2]++'