2012-11-06 354 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; 
}