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 > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-05-2009
digipak digipak is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 19
Help required with formatting

I would appreciate any help (sed / awk / perl) on the following question. I have the file in the following format. Note that the records are separated by the line that starts with the word "TRACE".I want the 5th and 6th values on the line starting with "TRACE" to be repeated down the file until the next record is hit (a line starting with the word TRACE). If this is my input file, then please have a look at the bottom i.e the output that I want using perl or awk.

INPUT
=======
TRACE mrjn05 6487 4922 358666.00 3154690.00 4 8
4 12068.6
12 12067.9
20 12066.7
28 12065.6
36 12064.7
44 12063.4
52 12062.1
60 12061.3
68 12060.9
76 12060.6
84 12057.9
92 12052.7
100 12052.1
TRACE mrjn05 6487 4923 358685.00 3154680.00 4 8
4 12068.6
12 12068
20 12066.9
28 12065.8
36 12064.7
44 12063.5
52 12062.2


OUTPUT
=======

TRACE mrjn05 6487 4922 358666.00 3154690.00 4 8
4 12068.6 358666.00 3154690.00
12 12067.9 358666.00 3154690.00
20 12066.7 358666.00 3154690.00
28 12065.6 358666.00 3154690.00
36 12064.7 358666.00 3154690.00
44 12063.4 358666.00 3154690.00
52 12062.1 358666.00 3154690.00
60 12061.3 358666.00 3154690.00
68 12060.9 358666.00 3154690.00
76 12060.6 358666.00 3154690.00
84 12057.9 358666.00 3154690.00
92 12052.7 358666.00 3154690.00
TRACE mrjn05 6487 4923 358685.00 3154680.00 4 8
4 12068.6 358685.00 3154680.00
12 12068 358685.00 3154680.00
20 12066.9 358685.00 3154680.00
28 12065.8 358685.00 3154680.00
36 12064.7 358685.00 3154680.00
44 12063.5 358685.00 3154680.00
52 12062.2 358685.00 3154680.00

Any help on this will be higly appreciated. The file is really huge (about 800 MB) and I am just a beginer. Please help.

Last edited by digipak; 05-05-2009 at 07:15 AM.. Reason: bad formatting