2012-11-06 304 views
1

可能重复:
Shell script for formatting outputshell脚本/命令

我有以下吐出的文字脚本JACL,我希望它更好formatted.How我能做到这个 ?

Stats for Cell=CELL Node=N01 Server=APP at 15:48:06 
Stats name=WebContainer, type=threadPoolModule 
name=PoolSize, ID=4, description=The average number of threads in a pool., unit=N/A, type=BoundedRangeStatistic, lowWaterMark=1, highWaterMark=50, current=4, integral=9.16145228E8, lowerBound=50, upperBound=50 
Stats name=ORB.thread.pool, type=threadPoolModule 
name=PoolSize, ID=4, description=The average number of threads in a pool., unit=N/A, type=BoundedRangeStatistic, lowWaterMark=1, highWaterMark=10, current=1, integral=1.26898089E8, lowerBound=10, upperBound=50 
Stats name=WorkManager.BPENavigationWorkManager, type=threadPoolModule 
name=PoolSize, ID=4, description=The average number of threads in a pool., unit=N/A, type=BoundedRangeStatistic, lowWaterMark=1, highWaterMark=10, current=5, integral=8.53089448E8, lowerBound=1, upperBound=5 
Stats name=WorkManager.BPESchedulerWorkManager, type=threadPoolModule 
name=PoolSize, ID=4, description=The average number of threads in a pool., unit=N/A, type=BoundedRangeStatistic, lowWaterMark=1, highWaterMark=1, current=0, integral=0.0, lowerBound=1, upperBound=5Scrits commands to convert the above to below.(Awk or sed ?) 

我怎么想看到输出。

CELL:N01:APP at 15:48:06 
WebContainer threadPool current=4 
ORB.thread.pool threadPool current=1 
WorkManager.BPENavigationWorkManager threadPool current=5 
WorkManager.BPESchedulerWorkManager threadPool current=0 
+1

请仔细阅读http://whathaveyoutried.com/,然后再试一次冒充你的问题。 – Johnsyweb

+0

样子:http://stackoverflow.com/questions/13259293/shell-script-for-formatting-output – squiguy

+0

大约有十几种不同的方式来从你输入的是输出,但要等到告诉我们为什么是这样的输出,我们只是猜测。我的意思是你拉出根据它周围,或基于它在线路或....位置一些文本?此外,你的线条是否在上面打包,或者名称= PoolSize是否真的从它自己的一行开始? –

回答

0

对于格式化,perl可能是要走的路。你也可以在命令行中使用perl。 http://www.perl.com/pub/2004/08/09/commandline.html

虽然你的目的,我建议你写一个简单的perlscript它看起来像

while(<>){ 
chomp; 
$line = $_; 
$line =~ s/Stats for Cell=//; 
$line =~ s/ Node=/:/; 
...etc 
print $line; 
}