how to awk a data from seperate lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to awk a data from seperate lines
# 1  
Old 08-11-2008
Java how to awk a data from seperate lines

Hi guys,

i have a problem which im hoping you will be able to help me with.

I have follwing output :-
-------------------------------------------------------------------------------
NSTEP = 407000 TIME(PS) = 43059.000 TEMP(K) = 288.46 PRESS = 0.0
Etot = -2077.4322 EKtot = 1259.9293 EPtot = -3337.3615
BOND = 354.7187 ANGLE = 793.3348 DIHED = 1116.0273
1-4 NB = 372.9656 1-4 EEL = 3636.2281 VDWAALS = -773.6836
EELEC = -5974.4091 EGB = -2898.5317 RESTRAINT = 0.0000
ESURF= 35.9885
------------------------------------------------------------------------------
NSTEP = 407500 TIME(PS) = 43060.000 TEMP(K) = 297.19 PRESS = 0.0
Etot = -2058.5407 EKtot = 1298.0826 EPtot = -3356.6233
BOND = 338.0366 ANGLE = 797.3124 DIHED = 1103.4133
1-4 NB = 375.9714 1-4 EEL = 3627.9377 VDWAALS = -788.2402
EELEC = -6205.8471 EGB = -2642.2325 RESTRAINT = 0.0000
ESURF= 37.0250
------------------------------------------------------------------------------

what i would like to do is extract the value TIME and ETOT. How can i do this with awk? im not great with awk so i dont know how to search for two different fields in one command, im sure there must be a way thou.

so far, ive been extracting each field seperatly using the following command:-

Code:
grep TEMP filename | awk '{print $6}' > time.dat

and then i would cut and paste each field in gedit.... however this is silly work around and id appreciate if someone could direct me to a better alternative.


Cheers


Mish

cut and paste the fields in nedit.
# 2  
Old 08-11-2008
This should be one way:
Code:
 awk '/TIME/{a=$6}/Etot/{print a, $3}' file > new_file

# 3  
Old 08-11-2008
Seems to do the trick, will save me lots of time.
Thank you very much


Mish
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - sed :Help Getting next lines data .

Experts, Can you please help how to get the output that are written just below "bad" calls badcalls nullrecv 439486 54 0 badlen xdrcall dupchecks ... (6 Replies)
Discussion started by: rveri
6 Replies

2. UNIX for Dummies Questions & Answers

How to seperate two lines that are joined?

i have something like this abc 123 3234 1234 * qqoiki * abc 4533 34 1234 * lloiki * i want to make it two lines i,e.,abc 123 3234 1234 * qqoiki * abc 4533 34 1234 * lloiki * how to do that ? (13 Replies)
Discussion started by: anurupa777
13 Replies

3. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

4. Shell Programming and Scripting

split a sentence and seperate into two lines

Hi, I have a string as str="route net,-hopcount,1,255.255.255.0,10.230.20.111,10.230.20.234 Route True route net,-hopcount,0,-netmask,255.255.248.0,0,10.230.23.254 Route True" I need to split this string into two lines as route net,-hopcount,1,255.255.255.0,10.230.20.111,10.230.20.234... (4 Replies)
Discussion started by: chaitanyapn
4 Replies

5. Shell Programming and Scripting

Seperate complicated fields with awk

Hello, I want to separate fields from an log output like this: 11-JUL-2008 23:14:25 * (CONNECT_DATA=(SERVICE_NAME=WUMMER.IM.HERE.EXELLENT.COM)(CID=(PROGRAM=D:\oracle\product\10.2.0\client_1\jdk\jre\bin\java.exe)(HOST=X900005199)(USER=FTET1))) *... (6 Replies)
Discussion started by: sdohn
6 Replies

6. UNIX for Dummies Questions & Answers

I want to seperate my data by time of day

Hi, I'm a newbie to unix. I have a txt file with my data, a list of events. Each event comes with a unix time. I want to seperate a months worth of events into those that occur during the day, and those at night. I have no clue how to go about this, please can someone push me in the right... (6 Replies)
Discussion started by: pmasterkim
6 Replies

7. Shell Programming and Scripting

Set lines of in a file to seperate vars

In a bash script, I'm looking for a way to set each matching line of a file into its own variable, or variable array. As an example, i have a crontab file with several entries: 00 23 * * * /usr/local/bin/msqlupdate -all 00 11 * * * /usr/local/bin/msqlupdate -inc 00 03 * * *... (2 Replies)
Discussion started by: lochraven
2 Replies

8. Shell Programming and Scripting

UNIX -> send data as excel in seperate cells

Hi I have a data file in UNIX as follows. I need to send this file in Mail as excel format. but the problem i face is i get the data all in single cells per row. what can i do to get the data in seperate cells. File -> attachment.xls data data data data data1 data1 ... (1 Reply)
Discussion started by: vj8436
1 Replies

9. UNIX for Dummies Questions & Answers

awk to seperate a string that has a dash

Hello I have this string XYZ-ABC DFT-ERT QWE-TYU I want to get the part after the dash. how to do that? thanks (2 Replies)
Discussion started by: melanie_pfefer
2 Replies

10. Shell Programming and Scripting

Need help to seperate data

Hello ALL, I really need help to grep data and store in particular format. I am struggling to write that script .Please help me to solve this problem otherwise i will loose my job... I have to compare 2 files and generate the staticts of the data. First file product.dat contains 2 column . ... (4 Replies)
Discussion started by: getdpg
4 Replies
Login or Register to Ask a Question