The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
parse through one text file and output many sophiadun UNIX for Dummies Questions & Answers 14 02-20-2008 06:08 AM
parse text file klick81 Shell Programming and Scripting 3 12-18-2006 12:04 PM
Parse Text file and send mails Amruta Pitkar UNIX for Dummies Questions & Answers 12 08-11-2006 04:56 AM
How to parse a text file with \034 as field and \035 as end of message delimiter? indianya Shell Programming and Scripting 1 08-26-2005 10:20 PM
parse text or complex grep ? jacost UNIX for Dummies Questions & Answers 4 04-29-2004 08:58 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 02-23-2007
craggm craggm is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 4
parse text file

I have a file that has a header followed by 8 columns of data. I want to toss out the header, and then write the data to another file with a different header and footer. I also need to grab the first values of the first and second column to put in the header.

How do I chop off the header? How do I read the first line to get the 1st 2 column values?

Thanks
  #2 (permalink)  
Old 02-23-2007
Deal_NoDeal Deal_NoDeal is offline
Registered User
  
 

Join Date: Feb 2007
Location: Boston, MA
Posts: 64
Use "head -1 file" to get the first line. Then use "awk" or "cut" to get the column values.
  #3 (permalink)  
Old 02-23-2007
craggm craggm is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 4
I can use head -23 file to strip out my header, but how do I then step line by line through the rest of the file?
  #4 (permalink)  
Old 02-23-2007
gopidesaboyina gopidesaboyina is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 29
paste your text file here and the out put you want..so accordingly we can write the command.
  #5 (permalink)  
Old 02-23-2007
craggm craggm is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 4
The input has 21 header lines and then:

2007/02/14 14:35:00.000 -3290487.916 5918823.251 -937336.4914 343.2155631 1370.243225 7504.940754
2007/02/14 14:36:00.000 -3262514.423 5987671.968 -485265.2305 588.8979381 923.8295738 7558.439209
2007/02/14 14:37:00.000 -3219871.692 6029597.035 -31005.43118 832.0042338 473.1283695 7577.860785
2007/02/14 14:38:00.000 -3162747.636 6044402.618 423394.2676 1071.424968 20.18994397 7563.097944

I want the output to be the same except for the date/time to be an increment in seconds from the first time:
0
60
120
etc...
  #6 (permalink)  
Old 02-24-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
awk   ' NR == 1 { x = substr($2,7,2) ; print } { x=x+60; sub(":[0-9][0-9]\\.",":"x".",$2); print } ' file
  #7 (permalink)  
Old 02-26-2007
craggm craggm is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 4
That still doesn't work, it only appends an incorrect number of seconds to the time.

My input is:

Ephemeris Report


...
...
...
...



UTC ECI Pos.x ECI Pos.y ECI Pos.z ECI Vel.x ECI Vel.y ECI Vel.z
meters meters meters m/sec m/sec m/sec


2007/02/14 14:35:00.000 -3290487.916 5918823.251 -937336.4914 343.2155631 1370.243225 7504.940754
2007/02/14 14:36:00.000 -3262514.423 5987671.968 -485265.2305 588.8979381 923.8295738 7558.439209
2007/02/14 14:37:00.000 -3219871.692 6029597.035 -31005.43118 832.0042338 473.1283695 7577.860785
2007/02/14 14:38:00.000 -3162747.636 6044402.618 423394.2676 1071.424968 20.18994397 7563.097944
2007/02/14 14:39:00.000 -3091396.287 6032016.360 875883.6179 1306.067023 -432.9220146 7514.205215
2007/02/14 14:40:00.000 -3006136.556 5992489.764 1324420.491 1534.861850 -884.1448333 7431.397557
2007/02/14 14:41:00.000 -2907350.655 5925997.845 1766980.355 1756.768150 -1331.424860 7315.046723
2007/02/14 14:42:00.000 -2795482.373 5832838.365 2201565.704 1970.776041 -1772.726794 7165.681230
2007/02/14 14:43:00.000 -2671034.953 5713430.291 2626215.312 2175.914098 -2206.046799 6983.981273
2007/02/14 14:44:00.000 -2534568.723 5568311.769 3039013.259 2371.251606 -2629.417536 6770.776200
2007/02/14 14:45:00.000 -2386698.515 5398137.633 3438097.768 2555.903143 -3040.918130 6527.041193
2007/02/14 14:46:00.000 -2228090.794 5203676.276 3821669.786 2729.034079 -3438.686801 6253.889806
2007/02/14 14:47:00.000 -2059460.490 4985805.802 4188001.060 2889.863602 -3820.928429 5952.568581
...
...
...


and I want the ouput to be:

0 -3290487.916 5918823.251 -937336.4914 343.2155631 1370.243225 7504.940754
60 -3262514.423 5987671.968 -485265.2305 588.8979381 923.8295738 7558.439209
120 -3219871.692 6029597.035 -31005.43118 832.0042338 473.1283695 7577.860785
180 -3162747.636 6044402.618 423394.2676 1071.424968 20.18994397 7563.097944
240 -3091396.287 6032016.360 875883.6179 1306.067023 -432.9220146 7514.205215
300 -3006136.556 5992489.764 1324420.491 1534.861850 -884.1448333 7431.397557
360-2907350.655 5925997.845 1766980.355 1756.768150 -1331.424860 7315.046723
420 -2795482.373 5832838.365 2201565.704 1970.776041 -1772.726794 7165.681230
480 -2671034.953 5713430.291 2626215.312 2175.914098 -2206.046799 6983.981273
540 -2534568.723 5568311.769 3039013.259 2371.251606 -2629.417536 6770.776200
600 -2386698.515 5398137.633 3438097.768 2555.903143 -3040.918130 6527.041193
660 -2228090.794 5203676.276 3821669.786 2729.034079 -3438.686801 6253.889806
720 -2059460.490 4985805.802 4188001.060 2889.863602 -3820.928429 5952.568581
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 12:28 AM.


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