Get distinct value in bash between two string

Sorry for my english i am french

So i am receiving from a script this prompt :

tabular;critical;mirroring;DG INTlocaldg VOLUME appears
tabular;critical;mirroring;DG INTlocaldg VOLUME bh3vm
tabular;critical;mirroring;DG INTlocaldg VOLUME dev
tabular;critical;mirroring;DG INTlocaldg VOLUME earsdev
tabular;critical;mirroring;DG INTlocaldg VOLUME earslivraison
tabular;critical;mirroring;DG INTlocaldg VOLUME earsrct
tabular;critical;mirroring;DG INTlocaldg VOLUME ed
tabular;critical;mirroring;DG INTlocaldg VOLUME eng
tabular;critical;mirroring;DG INTlocaldg VOLUME home
tabular;critical;mirroring;DG INTlocaldg VOLUME home_Ctibco6
tabular;critical;mirroring;DG INTlocaldg VOLUME home_adapter
tabular;critical;mirroring;DG INTlocaldg VOLUME icf
tabular;critical;mirroring;DG INTlocaldg VOLUME investigation
tabular;critical;mirroring;DG INTlocaldg VOLUME isa_dev
tabular;critical;mirroring;DG INTlocaldg VOLUME isa_rct
tabular;critical;mirroring;DG INTlocaldg VOLUME isa_share
tabular;critical;mirroring;DG INTlocaldg VOLUME livraison
tabular;critical;mirroring;DG INTlocaldg VOLUME mq
tabular;critical;mirroring;DG INTlocaldg VOLUME mqlog
tabular;critical;mirroring;DG INTlocaldg VOLUME mqprod
tabular;critical;mirroring;DG INTlocaldg VOLUME mqvar
tabular;critical;mirroring;DG INTlocaldg VOLUME netbackup
tabular;critical;mirroring;DG INTlocaldg VOLUME od-home
tabular;critical;mirroring;DG INTlocaldg VOLUME oracle
tabular;critical;mirroring;DG INTlocaldg VOLUME oradb
tabular;critical;mirroring;DG INTlocaldg VOLUME ov
tabular;critical;mirroring;DG INTlocaldg VOLUME rct
tabular;critical;mirroring;DG INTlocaldg VOLUME rc3
tabular;critical;mirroring;DG INTlocaldg VOLUME sar
tabular;critical;mirroring;DG INTlocaldg VOLUME soa
tabular;critical;mirroring;DG INTlocaldg VOLUME tibbh3
tabular;critical;tibco;DG INTlocaldg VOLUME tibco
tabular;critical;tibco;DG INTlocaldg VOLUME tibco_dev6
tabular;critical;tibco;DG INTlocaldg VOLUME tibco_rc2
tabular;critical;tibco;DG INTlocaldg VOLUME tibcobh3
tabular;critical;mirroring;DG INTlocaldg VOLUME tws00
tabular;critical;mirroring;DG INTlocaldg VOLUME unix
tabular;critical;was;DG INTlocaldg VOLUME was6
tabular;critical;was;DG INTlocaldg VOLUME was6dev
tabular;critical;was;DG INTlocaldg VOLUME was6devcells
tabular;critical;was;DG INTlocaldg VOLUME was6devlogs
tabular;critical;was;DG INTlocaldg VOLUME was6devproduct
tabular;critical;was;DG INTlocaldg VOLUME was6distrib
tabular;critical;was;DG INTlocaldg VOLUME was6rct
tabular;critical;was;DG INTlocaldg VOLUME was6rctcells
tabular;critical;was;DG INTlocaldg VOLUME was6rctlogs
tabular;critical;was;DG INTlocaldg VOLUME was6rctproduct
tabular;critical;was;DG INTlocaldg VOLUME was6share

I need to get the list of my error type
Basicly i need to get distinct value between 'critical'; and the third ';'
was
tibco
mirroring

in this exemple, but i can have lot of more.

Can i do this with one command, or should i put all in one table and compare every value ?

Hello cterra,

Welcome to the forums, special thanks for using the code tags as per forum rules :b:.
Could you please try following and let me know if this helps you. On a Solaris/SunOS system,
change awk to /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk .

awk -F";" '{A[$3]} END{for(i in A){print i}}'  Input_file

Output will be as follows.

was
mirroring
tibco
 

Thanks,
R. Singh

1 Like

Or

awk '!L[$3]++{print $3} ' FS=";" file
mirroring
tibco
was

Perfect, it s exactly what i am looking for, it will be run only on linux, thanks a lot