텍스트 파일:
***** Connected to QBBSC01 *****
MO
RXOTG-0
DEV DCP APUSAGE APSTATE 64K TEI
RBLT2-161 1 UNCONC SPEECH/DATA YES
RBLT2-162 2 UNDEF IDLE YES
RBLT2-163 3 UNCONC SPEECH/DATA YES
RBLT2-164 4 UNDEF IDLE YES
***** Disconnected from QBBSC01 *****
***** Connected to QBBSC04 *****
MO
RXOTG-23
DEV DCP APUSAGE APSTATE 64K TEI
RBLT2-161 1 UNCONC SPEECH/DATA YES
RBLT2-162 2 UNDEF IDLE YES
RBLT2-163 3 UNCONC SPEECH/DATA YES
RBLT2-164 4 UNDEF IDLE YES
RBLT2-165 5 UNCONC SPEECH/DATA YES
RBLT2-166 6 UNCONC SPEECH/DATA YES
RBLT2-167 7 UNDEF IDLE NO
RBLT2-168 8 UNCONC SPEECH/DATA NO
***** Disconnected from QBBSC04 *****
***** Connected to QBBSC05 *****
MO
RXOTG-7
DEV DCP APUSAGE APSTATE 64K TEI
RBLT2-161 1 UNCONC SPEECH/DATA YES
RBLT2-162 2 UNDEF IDLE YES
RBLT2-163 3 UNCONC SPEECH/DATA YES
RBLT2-164 4 UNDEF IDLE YES
RBLT2-165 5 UNCONC SPEECH/DATA YES
RBLT2-166 6 UNCONC SPEECH/DATA YES
***** Disconnected from QBBSC05 *****
원하는 출력:
NE MO DEV DCP APUSAGE APSTATE 64K TEI
QBBSC01 RXOTG-0 RBLT2-161 1 UNCONC SPEECH/DATA YES
QBBSC01 RXOTG-0 RBLT2-162 2 UNDEF IDLE YES
QBBSC01 RXOTG-0 RBLT2-163 3 UNCONC SPEECH/DATA YES
QBBSC01 RXOTG-0 RBLT2-164 4 UNDEF IDLE YES
NE MO DEV DCP APUSAGE APSTATE 64K TEI
QBBSC04 RXOTG-23 RBLT2-161 1 UNCONC SPEECH/DATA YES
QBBSC04 RXOTG-23 RBLT2-162 2 UNDEF IDLE YES
QBBSC04 RXOTG-23 RBLT2-163 3 UNCONC SPEECH/DATA YES
QBBSC04 RXOTG-23 RBLT2-164 4 UNDEF IDLE YES
QBBSC04 RXOTG-23 RBLT2-165 5 UNCONC SPEECH/DATA YES
QBBSC04 RXOTG-23 RBLT2-166 6 UNCONC SPEECH/DATA YES
QBBSC04 RXOTG-23 RBLT2-167 7 UNDEF IDLE NO
QBBSC04 RXOTG-23 RBLT2-168 8 UNCONC SPEECH/DATA NO
NE MO DEV DCP APUSAGE APSTATE 64K TEI
QBBSCO5 RXOTG-7 RBLT2-161 1 UNCONC SPEECH/DATA YES
QBBSCO5 RXOTG-7 RBLT2-162 2 UNDEF IDLE YES
QBBSCO5 RXOTG-7 RBLT2-163 3 UNCONC SPEECH/DATA YES
QBBSCO5 RXOTG-7 RBLT2-164 4 UNDEF IDLE YES
QBBSCO5 RXOTG-7 RBLT2-165 5 UNCONC SPEECH/DATA YES
QBBSCO5 RXOTG-7 RBLT2-166 6 UNCONC SPEECH/DATA YES
줄 번호를 고려하지 마십시오.
답변1
다양한 영역이 어떻게 다른지 질문에서 명확하지 않습니다. 그러나 귀하의 예를 들어 간단한 awk
프로그램은 다음과 같습니다.
/Connected/ { NE=$4 }
/RXOTG/ { MO=$1 }
/DEV/ { printf "\n\nNE %*s %s\n", -length(MO), "MO", $0 }
/RBLT2/ { print NE, MO, $0 }