예 -
테스트 로그:
ConductID: null; RunOpSequenceCode: 12345678; ClientID: null; FescoOfferID: null; PriorityCode: null; RowNumberStart: 0; FetchSize: 0; ChannelTypes: ER,PART; NigoIndicator: null; TreatmentTypeCode: null; DivisionName: null; DivisionCode: null; }
[11-21-2099 23:25:28] [OK #6:DAMN_BATCH ] T123Util setT123Columns
ConductID: null; RunOpSequenceCode: 12345678; ClientID: null; FescoOfferID: null; PriorityCode: null; RowNumberStart: 0; FetchSize: 0; ChannelTypes: ER,PART; NigoIndicator: null; TreatmentTypeCode: null; DivisionName: null; DivisionCode: null; }
[11-21-2099 23:25:28] [OK #6:DAMN_BATCH ] T123Util setT123Columns
ConductID: null; RunOpSequenceCode: 12345678; ClientID: null; FescoOfferID: null; PriorityCode: null; RowNumberStart: 0; FetchSize: 0; ChannelTypes: ER,PART; NigoIndicator: null; TreatmentTypeCode: null; DivisionName: null; DivisionCode: null; }
[11-21-2099 23:25:28] [OK #6:DAMN_BATCH ] T123Util setT123Columns WARN : UserDefined Tatty Error: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [72000]; error code [20001];
--- The error occurred in com//tmo/asfjn/jdaf/tkenjrt/terkj.xml
--- The error occurred while eating sandwich.
--- Check the tim-tim-nothing-boy.
--- Cause: java.sql.SQLException: ORA-00001: You suck.
ORA-06512: at "test_amp_tim.pkg", line 78
이제 스크립트에서 "UserDefined Tatty Error"를 찾아 "An error 발생..."부터 "You're too bad"까지 인쇄하기를 원합니다.
나는 grep -Fxq와 sed를 시도했지만 성공하지 못했습니다. 감사해요.
답변1
이 같은?
awk '# If we see the error, set t to 1
/UserDefined Tatty Error/ { t=1; next }
# If it's not a --- reset t to 0 (even if it's already 0)
!/^--- / { t=0 }
# If t==1 we are inside the error message; so, print
t' file
답변2
awk '/UserDefined Tatty Error/,/You suck/' file