how to print specific lines or words

Hi,

Please have a look on below records.

STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: The value of the row is: EMPLID = 220677 COMPANY = 919 BALANCE_ID = 0 BALANCE_YEAR = 2012
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: ORA-00001: unique constraint (SYSADM.PS_TAX_BALANCE) violated
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: DBMS.CODE=ORA-00001
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: The value of the row is: EMPLID = 220748 COMPANY = 919 BALANCE_ID = 0 BALANCE_YEAR = 2012
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: ORA-00034: Invalid Username and Passowrd
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: DBMS.CODE=ORA-00034
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: The value of the row is: EMPLID = 220748 COMPANY = 919 BALANCE_ID = 0 BALANCE_YEAR = 2012
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: ORA-00456: Invalid Employee ID
 
STG_HCM_STATE_DIS_TAX_TBL.1207.Xfm: DBMS.CODE=ORA-00456

In above scenario, there are 3 set of records for an individual employees (I mean first 3 records belong to EMPLID = 220677). Now I want to select only employee number and the error description for that employee.
In UNIX, how can I achieve the desired output in a new file like,

220677,unique constraint (SYSADM.PS_TAX_BALANCE) violated
220748,Invalid Username and Passowrd
220748,Invalid Employee ID

Try

awk '/EMPLID/{printf $10","}/ORA-[0-9]*:/{sub(".*ORA-[0-9]*: ","");printf $0"\n"}' file
1 Like

Hi

$ awk -F '[:=]' '/EMPLID/{printf "%d,",$4;getline;getline;print $3}' file
220677, unique constraint (SYSADM.PS_TAX_BALANCE) violated
220748, Invalid Username and Passowrd
220748, Invalid Employee ID

Guru.

1 Like

Try...

awk -F: '$3~/EMPLID/{split($3,a," ");printf "%s,",a[3]}$2~/^ ORA/{print $NF}' file1
1 Like

Thanks to all of you.

Ygor, its working perfectly.