- 论坛徽章:
- 0
|
我在使用一个取was的大对象的脚本的时候,内容如下:
find /install/IBM/WebSphere/AppServer/profiles/estore/logs/server1 -name "native_stderr.log" 2>/dev/null|grep -v nodeagent|while read FILE
do
cat -n $FILE|sed -n -e "/Jul 2[6-8].*2010/{
=;n;n;n;n;n;n;
/Allocation request for/{n;p;}
n;
/Allocation request for/{n;p;}
}" |sed -n -e '/at /{x;1!p;g;p;}' -e h |sed '$!N;s/\n/ /' |awk '{print "'$FILE' "$0}'
done |sort +3|uniq -f 3 -c |while read NUM FILES ROWID1 ROWID2 KEYWORD
do
echo $FILES |sed 's/^\(.*\)\/server1\/native_stderr.log/\2/'|read HOSTNAME
echo "\n抽样文件: $FILES\n共出现次数: $NUM"
cat $FILES |sed -n "${ROWID1},/^$/p"
done
这个脚本必须要用ksh执行的,用bash的话会认为脚本没有结束。
请问一下,能不能介绍下这个脚本是怎么处理文本的呢?过程作了什么操作呢?
它输出的结果类似如下的:
抽样文件: /install/IBM/WebSphere/AppServer/profiles/estore/logs/server1/native_stderr.log
共出现次数: 1
<GC(7891): GC cycle started Tue Jul 27 12:28:00 2010
<GC(7891): freed 100765928 bytes, 14% free (233579520/1610611200), in 15841 ms>
<GC(7891): mark: 496 ms, sweep: 45 ms, compact: 15300 ms>
<GC(7891): refs: soft 3 (age >= 32), weak 21, final 52, phantom 52>
<GC(7891): moved 14320015 objects, 685845944 bytes, reason=1, used 3640 more bytes>
<AF[4009]: completed in 15843 ms>
Allocation request for 8388624 bytes
at org.extremecomponents.table.filter.ExportFilter.doFilterInternal(ExportFilter.java:4
at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(AbstractExportFilter.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java(Compiled Code))
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java(Compiled Code))
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Allocation request for 16777232 bytes
at org.extremecomponents.table.filter.ExportFilter.doFilterInternal(ExportFilter.java:4
at org.extremecomponents.table.filter.AbstractExportFilter.doFilter(AbstractExportFilter.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java(Compiled Code))
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java(Compiled Code))
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
另外想请问一下,我在linux下执行这个脚本的时候,用ksh,会报出
sed:-e 表达式 #1,字符 41:invalid reference \2 on `s' command's RHS
请问是不是版本的问题呢?
sed --version
GNU sed version 4.1.4
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
恳请各位指点一下我这两个问题,谢谢。 |
|