![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 02:25 AM |
| extracting XML file using sed | pujansrt | Shell Programming and Scripting | 7 | 06-29-2007 01:18 PM |
| [Splitting file] Extracting group of segments from one file to others | ozgurgul | Shell Programming and Scripting | 1 | 09-14-2006 12:17 PM |
| extracting from a tar file | Reza Nazarian | UNIX for Dummies Questions & Answers | 4 | 03-24-2006 05:54 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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
|
|
||||
|
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 |
|
||||
|
Code:
ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/bufg4.GCLKMUX 5 118.8 0.9 1.4 ddrsp0.ddr0/ddr_phy0/xc2v.ddr_phy0/mclk 0 12 118.8 2.2 3.4 |
| Sponsored Links | ||
|
|