Remove interspersed headers in .dat file with AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove interspersed headers in .dat file with AWK
# 1  
Old 08-10-2011
Remove interspersed headers in .dat file with AWK

Heya there,

A small selection of my data is shown below.

Code:
DATE                      TIME                      FRAC_DAYS_SINCE_JAN1      
2011-06-25                08:03:20.000              175.33564815 
2011-06-25                08:03:25.000              175.33570602
2011-06-25                08:03:30.000              175.33576389 
2011-06-25                08:03:35.000              175.33582176

There are a lot more headers and about 20 days worth of data in this one file. The problem I have is that this .dat file has been concatenated from many individual files, for which I used the following code.

Code:
find /u/gd9629/private/Scripts/Gavin/picarro -type f -name "CF*nc.dat" -exec cat {} > /u/gd9629/private/Scripts/Gavin/Data/june2011.dat \;

This also concatenates all the headers which are at the top of each individual file. Is there a way to remove all the interspersed headers throughout my combined .dat file?

Thanks
# 2  
Old 08-10-2011
Assuming the concatenated file as to be in below format..
Code:
DATE                      TIME                      FRAC_DAYS_SINCE_JAN1
2011-06-25                08:03:20.000              175.33564815
2011-06-25                08:03:25.000              175.33570602
DATE                      TIME                      FRAC_DAYS_SINCE_JAN1
2011-06-25                08:03:20.000              175.33564815
2011-06-25                08:03:35.000              175.33582176
DATE                      TIME                      FRAC_DAYS_SINCE_JAN1
2011-06-25                08:03:30.000              175.33576389
2011-06-25                08:03:35.000              175.33582176

Try..
Code:
sed '1!{/DATE/d}' inputfile.dat

This User Gave Thanks to michaelrozar17 For This Post:
# 3  
Old 08-10-2011
Hey Michael,

that code worked! I had to write the input file to a few one i.e.

Code:
sed '1!{/DATE/d}' inputfile1.dat > inputfile2.dat

Thanks a lot!
# 4  
Old 08-10-2011
Code:
awk 'NR>1 && /[A-Z]/{next}1' file

# 5  
Old 08-10-2011
Using the same concept, I need to remove 6 lines of a data frame and those interspersed throughout.

Code:
10 May 2011 Created: 10 May 11 15:05 GMT Scale: SIO-2005 and others
GC-MD, Cape Grim, Tasmania, Lat.: 40.68S, Lon.: 144.69E, Alt: 94m above sea level
You can use the following format in Fortran to read data in different columns, (F10.5, 2I4,I6, 2I4,I6,1X,10(F10.3,a1))
    scale:  --  --    --  --  --    --     SIO-05     SIO-05     SIO-05     SIO-05     SIO-98     SIO-05 Tohoku-Uni     SIO-98    CSIRO94    CSIRO94
     unit:  --  --    --  --  --    --        ppt        ppt        ppt        ppt        ppb        ppt        ppb        ppt        ppb        ppb
      time  DD  MM  YYYY  hh min ABSDA     CFC-11     CFC-12    CH3CCl3       CCl4        N2O    CFC-113        CH4      CHCl3         CO         H2
2010.00004   1   1  2010   0  23 11628    239.925    533.582      8.181     86.203    322.195     75.690   1736.198      4.644     35.280    529.335 
2010.00012   1   1  2010   1   3 11628    239.436    533.013      8.224     86.178    321.900     75.496   1735.882      4.892     34.441    527.677 
2010.00020   1   1  2010   1  43 11628    239.884    533.140      7.948     85.851    322.215     75.451   1736.369      4.557     34.916    531.719 
2010.00027   1   1  2010   2  23 11628    239.977    533.657      8.383     86.410    322.339     75.445   1736.773      4.598     34.633    527.731 
2010.00035   1   1  2010   3   3 11628    239.687    533.042      8.032     86.418    322.198     75.405   1735.862      4.534     32.125    527.888 
2010.00042   1   1  2010   3  43 11628    239.733    533.058      7.837     86.113    322.212     75.436   1736.022      4.831     33.056    527.984

i.e. just remove all text bar the first 6 lines at the very top of the concatenated file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk command on .DAT file not working?

Hi All, I am trying to run awk command on .DAT file and it is not working. The same command is working on .txt file: Contents of the file ZZ_55555555_444444_ZZZZZZ_7777777_888_99.DAT: HEADER|ZZ_55555555_444444_ZZZZZZ_7777777_888_99.DAT... (10 Replies)
Discussion started by: sagar.cumar
10 Replies

2. Shell Programming and Scripting

Remove <CR><LF> from the dat file in unix

Hi, The source system has created the file in the dat format and put into the linux directory as mentioned below. I want to do foloowing things. a) Delete the Line started with <CR><LF> in the record b)Also line ...........................................................<CR><LF> ... (1 Reply)
Discussion started by: mr_harish80
1 Replies

3. UNIX for Dummies Questions & Answers

Using sed command to remove multiple instances of repeating headers in one file?

Hi, I have catenated multiple output files (from a monte carlo run) into one big output file. Each individual file has it's own two line header. So when I catenate, there are multiple two line headers (of the same wording) within the big file. How do I use the sed command to search for the... (1 Reply)
Discussion started by: rebazon
1 Replies

4. Shell Programming and Scripting

How to remove duplicates from the .dat file

All, I have a file 1181CUSTOMER-L061411_003500.dat.Z having duplicate records in it. bash-2.05$ zcat 1181CUSTOMER-L061411_003500.dat.Z|grep "90876251S" 90876251S|ABG, AN ADAYANA COMPANY|3550 DEPAUW BLVD|||US|IN|INDIANAPOLIS||DAL|46268||||||GEN|||||||USD|||ABG, AN ADAYANA... (3 Replies)
Discussion started by: Oracle_User
3 Replies

5. Shell Programming and Scripting

Filter/remove duplicate .dat file with certain criteria

I am a beginner in Unix. Though have been asked to write a script to filter(remove duplicates) data from a .dat file. File is very huge containig billions of records. contents of file looks like 30002157,40342424,OTC,mart_rec,100, ,0 30002157,40343369,OTC,mart_rec,95, ,0... (6 Replies)
Discussion started by: mukeshguliao
6 Replies

6. Shell Programming and Scripting

How to pull info under headers in file(awk,grep,while loop)

below is an extract from my file and I am trying to use Awk and grep and a while loop to pull infomation from under neath "HBA WWN=".HBA WWN=" reoccurs all over the file but the 100000c.....number are unique and I want to be able to pull and reference specifi information under this header ever time... (2 Replies)
Discussion started by: kieranfoley
2 Replies

7. Shell Programming and Scripting

Merging of files with different headers to make combined headers file

Hi , I have a typical situation. I have 4 files and with different headers (number of headers is varible ). I need to make such a merged file which will have headers combined from all files (comman coluns should appear once only). For example - File 1 H1|H2|H3|H4 11|12|13|14 21|22|23|23... (1 Reply)
Discussion started by: marut_ashu
1 Replies

8. Shell Programming and Scripting

Remove text between headers while leaving headers intact

Hi, I'm trying to strip all lines between two headers in a file: ### BEGIN ### Text to remove, contains all kinds of characters ... Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c om/updates/ Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies

9. Shell Programming and Scripting

Remove Headers throughout a data file

I have a data file with over 500,000 records/lines that has the header throughout the file. SEQ_ID Name Start_Date Ins_date Add1 Add2 1 Harris 04/02/08 03/02/08 333 Main Suite 101 2 Smith 02/03/08 01/23/08 287 Jenkins SEQ_ID Name ... (3 Replies)
Discussion started by: psmall
3 Replies

10. UNIX for Dummies Questions & Answers

help:how to remove headers in output file

Hi I am running a script (which compares two directory contents) for which I am getting an output of 70 pages in which few pages are blank so I was able to delete those blank lines. But I also want to delete the headers present for each page. can any one help me by providing the code... (1 Reply)
Discussion started by: raj_thota
1 Replies
Login or Register to Ask a Question