Extract Velocity Data (Loc, Time, Velocity)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract Velocity Data (Loc, Time, Velocity)
# 1  
Old 09-28-2011
Extract Velocity Data (Loc, Time, Velocity)

Hi ,

I am just learning awk and wanted to do the following :

Data (Velocity Data) Function of Hanvdel with time/velocity pair;

Code:
HANDVEL 20288 
20 9243 160 10658 204 11365 336 12651
444 13444 560 13937 652 14237 776 14537
924 15159 1052 15438 1168 15523 1316 15309
1452 15137 1736 15416 1824 15673 2164 16852
2516 17967 2864 18545 5996 22188
**location 20384 0 2 
HANDVEL 20384 
12 9243 172 10165 296 12201 352 12930
444 13444 564 14044 628 14280 748 14602
904 14987 1024 15137 1128 15266 1292 15180
1444 15073 1720 15288 1824 15459 2156 16831
2520 17988 2868 18567 5996 22188
**location 20480 0 2 
HANDVEL 20480 
4 9222 172 10208 248 11430 352 12951
436 13423 556 13959 648 14302 744 14537
896 14945 1024 15202 1132 15245 1296 15116
1436 15009 1720 15416 1828 15652 2132 16509
2300 17152 2524 17924 2852 18567 5996 22188
**location 20576 0 2


Outcome:
Wanted to capture "HANDVEL Value" "Time" "Velocity" per line

Code:
20288 20 9243
20288 160 10658
....
20384 12 9243
20384 172 10165

...

Appreciate your help.
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 09-28-2011 at 05:58 PM.. Reason: code tags, please!
# 2  
Old 09-28-2011
Code:
nawk '/^HANDVEL/ {hand=$2}/^[0-9]/ {for(i=1; i<=NF;i+=2) print hand, $i, $(i+1)}' myFile

# 3  
Old 09-28-2011
Thank you . I am currently running Red Hat Linux 2.1? and nawk is not available. Any suggestion of executing with regular awk or gawk.
# 4  
Old 09-28-2011
try with awk
# 5  
Old 09-29-2011
No output. I tried awk '/HANDVEL/ {print $2}' myfile and got all my HANDVEL Values . This suggested that awk works.

Last edited by radoulov; 09-29-2011 at 10:02 AM.. Reason: Code tags!
# 6  
Old 09-29-2011
Code:
$awk '/HANDVEL/ {a=$2} /^[0-9]/ {for(i=1;i<=NF;i+=2){print a,$i,$(i+1)}}' input

# 7  
Old 09-29-2011
Still no output.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

2. Shell Programming and Scripting

Extract data from log file within specified time

So, we have a script, that is supposed to have a couple of functions like showing number of failed connections, recieved bytes per IP-address, and so on. We are supposed to be able to limit the number of results to either 0-24 hours or X days back from the last data in the log file. Everything... (3 Replies)
Discussion started by: Plumpen
3 Replies

3. Shell Programming and Scripting

Extract data from log file in specified range of time

I was searching for parsing a log file and found what I need in this link http://stackoverflow.com/questions/7575267/extract-data-from-log-file-in-specified-range-of-time But the most useful answer (posted by @Kent): # this variable you could customize, important is convert to seconds. # e.g... (2 Replies)
Discussion started by: kingk110
2 Replies

4. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

5. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

6. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

7. Shell Programming and Scripting

How to get data between the start time and end time?

Hi, Can anyone help me how can I get the line that between the start time and end time. file1.txt 15/03/2009 20:45:03 Request: - Data of this line 15/03/2009 20:45:12 Response: - Data of this line 15/03/2009 22:10:40 Request: - Data of this line 15/03/2009 22:10:42 Response: - Data of... (1 Reply)
Discussion started by: tanit
1 Replies

8. Shell Programming and Scripting

To extract data of a perticular interval (date-time wise)

I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)
Discussion started by: abhishek27
3 Replies

9. Programming

Counting LOC in C

Hi Do you know where I can find any utility that counts lines of code in a C program, accurately? The ones that count the semicolons does not give correct results. Thanx Andonis Matsakas (1 Reply)
Discussion started by: amatsaka
1 Replies
Login or Register to Ask a Question