テキストファイル:
***** 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 }