ファイル1:
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:940)
at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:198)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:712)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:469)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1230)
РЯа. 19, 2021 4:14:16 PM com.lhs.ccb.sfw.application.ServiceObjectImpl executeLocaleI
SEVERE: ServiceObjectI.executeLocaleI CONTRACT.WRITE
ファイル2:
Error code: CommonDomain.InvalidStateTransition
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1700)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1558)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:940)
at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:198)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:712)
РЯа. 19, 2021 4:14:16 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:14:16 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:15:42 PM com.lhs.ccb.sfw.application.ServiceObjectImpl executeLocaleI
SEVERE: ServiceObjectI.executeLocaleI CONTRACT.WRITE
ファイル3:
Error code: CommonDomain.InvalidStateTransition
at com.lhs.ccb.sfw.application.ServiceObjectImpl.execute(Unknown Source)
at com.lhs.cil.core.AggregatedServiceObjectImpl.execute(Unknown Source)
at com.lhs.ccb.sfw.application.ServiceObjectImpl.executeLocaleI(Unknown Source)
at com.lhs.cil.core.AggregatedServiceObjectImpl.executeLocaleI(Unknown Source)
at com.lhs.ccb.soi.ServiceObjectIPOA._invoke(Unknown Source)
РЯа. 19, 2021 4:20:21 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:20:21 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:21:22 PM com.lhs.ccb.sfw.application.ServiceObjectImpl executeLocaleI
SEVERE: ServiceObjectI.executeLocaleI CONTRACT.WRITE
Error code: CommonDomain.InvalidStateTransition
at com.lhs.CommonDomain.bscs_core.ae.a(Unknown Source)
at com.lhs.cil.core.AggregatedServiceObjectImpl.execute(Unknown Source)
at com.lhs.ccb.sfw.application.ServiceObjectImpl.executeLocaleI(Unknown Source)
at com.lhs.cil.core.AggregatedServiceObjectImpl.executeLocaleI(Unknown Source)
at com.lhs.ccb.soi.ServiceObjectIPOA._invoke(Unknown Source)
РЯа. 19, 2021 4:21:22 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:21:22 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:26:22 PM com.lhs.ccb.sfw.application.ServiceObjectImpl executeLocaleI
SEVERE: ServiceObjectI.executeLocaleI CONTRACT.WRITE
Error code: CommonDomain.InvalidStateTransition
at com.lhs.ccb.sfw.application.ServiceObjectImpl.execute(Unknown Source)
at com.lhs.cil.core.AggregatedServiceObjectImpl.execute(Unknown Source)
at com.lhs.ccb.sfw.application.ServiceObjectImpl.executeLocaleI(Unknown Source)
at com.lhs.cil.core.AggregatedServiceObjectImpl.executeLocaleI(Unknown Source)
at com.lhs.ccb.soi.ServiceObjectIPOA._invoke(Unknown Source)
РЯа. 19, 2021 4:26:22 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:26:22 PM com.lhs.FrameworkExtension.bscs_core.d getErrorMessage
WARNING: no localized text available for:
ErrorCode : InvalidStateTransition
BundleName: CommonDomain_ErrorDictionary
Locale : en_US
Reason : XMlResourceException: ResourceBundleManager: Can not find resource bundle 'CommonDomain_ErrorDictionary'
РЯа. 19, 2021 4:30:40 PM com.lhs.ccb.sfw.application.ServiceObjectImpl executeLocaleI
SEVERE: ServiceObjectI.executeLocaleI CONTRACT.WRITE
最初のファイルを読み取るのと同じ方法でこのファイルを読み取り、strict1からSEVERE行を抽出し、warning1からWARNING行を抽出するシェルスクリプトを作成したいと思います。次に、Severe2のSEVERE行とwarning2のWARNING行が最後のファイル(10ファイル)と同じになるように2番目のファイルを渡します。これを行う最も簡単な方法は何ですか?
私が確認した方法は次のとおりです。 **
for i in (ls *.log); do
cat *.log|grep "SEVERE" > severe$i.txt
cat *.log|grep "WARNING" > warning$i.txt
done;
**
ベストアンサー1
コードにはいくつかの問題があります。
for i in (ls *.log); do
- 逆に
(...)
、そうすべき$(...)
ですが、まったくそうする必要はありません。なぜなら… - 出力を解析しないでください。
ls
、代わりに使用for f in *.log; do
- カウンター
$i
ではなくファイル名なので、カウンターを手動で追加する必要があります。内部ループi=0
などのループと増分前。i=$((i+1))
(その後、使用for f in *.log
)。
cat *.log|grep "SEVERE" > severe$i.txt
このイベント自体には「間違っている」ことはありませんが、このイベントにはまだ問題があります。
grep
ファイルから読み取る、次は必要ありませんcat
。grep -h "SEVERE" *.log > severe$i.txt
*.log
各ファイルのメッセージを別々に読みたい場合は、なぜ読む必要がありますか?-F
パフォーマンスを向上させるにはgrep
。間違ったパターンを一致させずに単語全体を一致させるには、を追加します
-w
。良い習慣は、変数ファイル名を二重引用符で囲むことです - >
... > "severe$i.txt"
要約すると、次のようになります。
i=0
for f in *.log; do
i=$((i+1))
grep -Fw "SEVERE" "$f" > "severe$i.txt"
grep -Fw "WARNING" "$f" > "warning$i.txt"
done
またはすべて一つでawk
:
awk '
FNR==1{FILENUM+=1}
/^SEVERE/{print > "severe"FILENUM".txt"}
/^WARNING/{print > "warning"FILENUM".txt"}
' *.log