The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to view the contents of .gz file without extracting the file? amitkhiare Shell Programming and Scripting 10 12-18-2008 05:59 AM
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-10-2007 03:25 AM
extracting XML file using sed pujansrt Shell Programming and Scripting 7 06-29-2007 02:18 PM
[Splitting file] Extracting group of segments from one file to others ozgurgul Shell Programming and Scripting 1 09-14-2006 01:17 PM
extracting from a tar file Reza Nazarian UNIX for Dummies Questions & Answers 4 03-24-2006 05:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-24-2007
hack_tom hack_tom is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 11
Extracting from file

Hi I have the file in following format

Begining of file
---------------------------------------
my name some dfgfgfk jdksjdkls laladsl sdlsdls
.
.
.
kfdjkfdk some drt pro vhdl sdjls.
----------------------------------------------------------------
ddr.spw.df.df 0 0 0 0 0
ddr.ser.ddf.tp 1 2 3 4 1
ddr.pwq.pro.fgt.tp 1 3 4 5 7
eth.pro.iw 1 2 3 4 5
eth.3po.lk 1 2 5 6 7
eth.3yu.lo 3 4 5 6 9

--------------------------------------------------------
end of file

Now I want to seprate all lines begining with ddr and sum their 5th column, similiarly I want to seprate all lines begining with eth and sum their 5th column. The top portion of file as shown might consist of some paragraph which I don't need to consider. So please can anyone help with perl script to perform this operation.

Thanks
  #2 (permalink)  
Old 04-24-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398

Code:
perl -ane ' if ( /^ddr/ ){ $ddr = $ddr+ $F[5]; } 
if( /^eth/ ) { $eth = $eth + $F[5]; } 
END {
	print "ddr $ddr \n" ;
	print "eth $eth\n" ;
}' file

  #3 (permalink)  
Old 04-24-2007
hack_tom hack_tom is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 11
thanks for quick reply can I execute this code from a file for ex. pr.pl and then execute perl pr.pl?? Also what changes I need to made if I want to dump the result in a file??
  #4 (permalink)  
Old 04-24-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
pr.pl

Code:
perl -ane ' if ( /^ddr/ ){ $ddr = $ddr+ $F[5]; } 
if( /^eth/ ) { $eth = $eth + $F[5]; } 
END {
	print "ddr $ddr \n" ;
	print "eth $eth\n" ;
}' file > outputfile

Just run with the filename pr.pl and output is sent to outputfile.
  #5 (permalink)  
Old 04-24-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,556

Code:
awk 'BEGIN{}
	/^ddr/ { ddr += $5}
	/^eth/ { eth+=$5 }
END {
     print "ddr count is " ddr
     print "eth count is " eth
     } ' "file"

  #6 (permalink)  
Old 04-26-2007
hack_tom hack_tom is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 11
Thanks for all replies. But I these code is not working for my case so I am again posting my original file for which I need to do my computation

--------------------------------------------------------------
----------------------------------------------------------------
Release 8.2i - XPower SoftwareVersion:I.31
Power summary: I(mA) P(mW)
----------------------------------------------------------------
Total estimated power consumption: 1506
---
Vccint 1.50V: 296 444
Vccaux 2.50V: 167 418
Vcco33 3.30V: 1 4
Vcco25 2.50V: 256 640
---
Clocks: 172 258
IOs: 143 434
Inputs: 2 3
Logic: 0 0
Outputs:
Vcco25 124 311
Vcco33 0 0
Signals: 0 0
---
Quiescent Vccint 1.50V: 50 75
Quiescent Vccaux 2.50V: 167 418
Quiescent Vcco33 3.30V: 1 4
Quiescent Vcco25 2.50V: 1 3
Startup Vccint 1.5V: 500
Startup Vccaux 2.5V: 250
Startup Vcco33 3.3V: 100
Startup Vcco25 2.5V: 100

Thermal summary:
----------------------------------------------------------------
Estimated junction temperature: 25C
250 LFM 25C
500 LFM 25C
750 LFM 25C
Ambient temp: 25C
Case temp: 25C
Theta J-A: 0C/W

Decoupling Network Summary: Cap Range (uF) #
----------------------------------------------------------------
Capacitor Recommendations:
Total for Vccint : 32
470.0 - 1000.0 : 1
4.70 - 10.00 : 1
0.470 - 2.200 : 3
0.0470 - 0.2200 : 6
0.0100 - 0.0470 : 10
0.0010 - 0.0047 : 11
---
Total for Vccaux : 16
470.0 - 1000.0 : 1
0.470 - 2.200 : 1
0.0470 - 0.2200 : 3
0.0100 - 0.0470 : 5
0.0010 - 0.0047 : 6
---
Total for Vref : 19
0.0470 - 0.2200 : 9
0.0100 - 0.0470 : 10
---
Total for Vcco25 : 8
470.0 - 1000.0 : 1
0.0470 - 0.2200 : 1
0.0100 - 0.0470 : 2
0.0010 - 0.0047 : 4
---
Total for Vcco33 : 8
470.0 - 1000.0 : 1
0.0470 - 0.2200 : 1
0.0100 - 0.0470 : 2
0.0010 - 0.0047 : 4

Power details:
-------------------------------------------------------------------------------
Clocks:4 Loads Loading(fF) C(pF) F(MHz) I(mA) P(mW)
-------------------------------------------------------------------------------
clk_pad/xcv2.u0/ol
Logic:
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/dll 20 118.8

3.6 5.3
clkgen0/xc2v.v/dll0 20 100.0 3.0 4.5
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/clkscale.dllm 20

100.0 3.0 4.5
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/bufg1.GCLKMUX 5

118.8 0.9 1.4
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/bufg2.GCLKMUX 5

118.8 0.9 1.4
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/bufg3.GCLKMUX 5

118.8 0.9 1.4
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/bufg4.GCLKMUX 5

118.8 0.9 1.4
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/clkscale.bufg0.GCLKMUX

5 118.8 0.9 1.4
clk_pad/xcv2.u0/g2.ttl0.bf.GCLKMUX 5 100.0 0.8

1.1
clkgen0/xc2v.v/bufg1.GCLKMUX 5 100.0 0.8 1.1
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/clkscale.bufg1.GCLKMUX

5 100.0 0.8 1.1
clkgen0/xc2v.v/bufg0.GCLKMUX 5 69.5 0.5 0.8
Nets:
clkm 0 769 69.5 80.3 120.4
clkml 0 94 118.8 16.8 25.2
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/clk_0r 0 51 118.8

9.3 13.9
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/clk_90r 0 43 118.8

7.8 11.7
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/clk_180r 0 40 118.8

7.2 10.7
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/mclk 0 12 118.8

2.2 3.4

----------------------------------------------------------------------
this is how my original file look exactly. so will it be possible to sum P(mW) column for all lines beginining with ddrsp0. Problem is that that all the values for a particular line beginning with ddrsp0 might not be on the same line like

ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/mclk 0 12 118.8

2.2 3.4

so what can I do for this because above mentioned scripts are not working properly in this case.

Thanks
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0