Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How get only required lines & delete the rest of the lines in file Post 302426129 by reva on Tuesday 1st of June 2010 01:24:03 AM
Old 06-01-2010
Question How get only required lines & delete the rest of the lines in file

Hiiii
I have a file which contains huge data as
a.dat:
HTML Code:
 PDE 1990  1  9 18 51 28.90  24.7500   95.2800 118.0 6.1 0.0 BURMA
event name:     010990D
time shift:      7.3000
half duration:   5.0000
latitude:       24.4200
longitude:      94.9500
depth:         129.6000
Mrr:       2.016000e+25
Mtt:      -1.576000e+25
Mpp:      -4.390000e+24
Mrt:      -2.089000e+25
Mrp:      -1.011000e+25
Mtp:       1.012000e+25

 PDE 1990  1 10 11 53 21.20  11.6000   95.1900  33.0 5.3 5.4 ANDAMAN ISLANDS REGION
event name:     011090D
time shift:      1.6000
half duration:   2.5000
latitude:       11.7100
longitude:      95.0300
depth:          61.0000
Mrr:      -2.770000e+23
Mtt:      -2.288000e+24
Mpp:       2.565000e+24
Mrt:       6.300000e+22
Mrp:      -1.190000e+24
Mtp:       6.836000e+24

 PDE 1990  1 22 17 26 12.10   3.8500   96.1000  51.0 6.0 0.0 NORTHERN SUMATERA
event name:     012290D
time shift:      7.1000
half duration:   5.0000
latitude:        3.5500
longitude:      95.9300
depth:          50.1000
Mrr:       1.837000e+25
Mtt:      -1.010000e+25
Mpp:      -8.270000e+24
Mrt:       1.084000e+25
Mrp:      -1.030000e+25
Mtp:       1.330000e+25

 PDE 1990  2  5  5 16 45.10  37.0700   71.2700 102.0 6.1 0.0 AFGHANISTAN-USSR BORDER
event name:     020590A
time shift:      8.4000
half duration:   4.9000
latitude:       36.5600
longitude:      70.8400
depth:         113.5000
Mrr:       1.749000e+25
Mtt:      -2.940000e+25
Mpp:       1.191000e+25
Mrt:      -7.030000e+24
Mrp:      -1.093000e+25
Mtp:      -5.500000e+23
I just want to retain first line & delete rest of the lines in the file
THe output file should be like
b.dat
Code:
 PDE 1990  1  9 18 51 28.90  24.7500   95.2800 118.0 6.1 0.0 BURMA
 PDE 1990  1 10 11 53 21.20  11.6000   95.1900  33.0 5.3 5.4 ANDAMAN ISLANDS
 PDE 1990  1 22 17 26 12.10   3.8500   96.1000  51.0 6.0 0.0 NORTHERN SUMATERA
 PDE 1990  2  5  5 16 45.10  37.0700   71.2700 102.0 6.1 0.0 AFGHANISTAN-USSR BORDER

Help me out.....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required regarding Extracting lines from a file

I have a file containing the following contents All of us, including Zippy, our dog All of us, including Zippy and Zippy All of us, including Zippy and Zippy and Zelda Testing All of us Zippy Now, i wanna grep and get the lines which has only one occurance of word Zippy and starting with... (1 Reply)
Discussion started by: google_ever
1 Replies

2. Shell Programming and Scripting

SED: match pattern & delete matched lines

Hi all, I have the following data in a file x.csv: > ,this is some text here > ,,,,,,,,,,,,,,,,2006/11/16,0.23 > ,,,,,,,,,,,,,,,,2006/12/16,0.88 < ,,,,,,,,,,,,,,,,this shouldnt be deleted I need to use SED to match anything with a > in the line and delete that line, can someone help... (7 Replies)
Discussion started by: not4google
7 Replies

3. Shell Programming and Scripting

To extract the required lines from a file

I have a files in a directory in this format data data data ---BEGIN CERT----- data data data ---END CERT ----- Now, I want to extract the lines starting from --BEGIN CERT-- and write the contents till the end of file into a new file.How can I do this for all the files in the... (1 Reply)
Discussion started by: sureshg
1 Replies

4. Shell Programming and Scripting

How to delete lines in a file that have duplicates or derive the lines that aper once

Input: a b b c d d I need: a c I know how to get this (the lines that have duplicates) : b d sort file | uniq -d But i need opossite of this. I have searched the forum and other places as well, but have found solution for everything except this variant of the problem. (3 Replies)
Discussion started by: necroman08
3 Replies

5. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

6. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

7. Shell Programming and Scripting

Sed/awk to delete single lines that aren't touching other lines

Hello, I'm trying to figure out how to use sed or awk to delete single lines in a file. By single, I mean lines that are not touching any other lines (just one line with white space above and below). Example: one two three four five six seven eight I want it to look like: (6 Replies)
Discussion started by: slimjbe
6 Replies

8. Shell Programming and Scripting

Delete 40 lines after every 24 lines from a file

Hello, I have file of more than 10000 lines. I want to delete 40 lines after every 20 lines. e.g from a huge file, i want to delete line no from 34 - 74, then 94 - 134 etc and so on. Please let me know how i can do it. Best regards, (11 Replies)
Discussion started by: nehashine
11 Replies

9. Shell Programming and Scripting

sed one liner to Delete blank lines - Help required

Hi, cat test.txt BlankLine BlankLine BlankLine BlankLine ello hi helo BlankLine BlankLine heylo BlankLine BlankLine BlankLine done BlankLine BlankLine BlankLine (1 Reply)
Discussion started by: TomG
1 Replies

10. UNIX for Beginners Questions & Answers

How to search & delete inclusively between two lines?

Hi all, I was wondering if anyone would know how to search & delete inclusively between two lines, please: Important: There are multiple }; lines. I'm curious how to delete the correct one only. Line numbers may vary each time this script is run. For example, I'd like to delete only the... (6 Replies)
Discussion started by: chatguy
6 Replies
Net::DNS::RR::LOC(3)					User Contributed Perl Documentation				      Net::DNS::RR::LOC(3)

NAME
Net::DNS::RR::LOC - DNS LOC resource record SYNOPSIS
use Net::DNS; $rr = new Net::DNS::RR('name LOC latitude longitude altitude size hp vp'); DESCRIPTION
DNS geographical location (LOC) resource records. METHODS
The available methods are those inherited from the base class augmented by the type-specific methods defined in this package. Use of undocumented package features or direct access to internal data structures is discouraged and could result in program termination or other unpredictable behaviour. latitude $latitude = $rr->latitude; ($deg, $min, $sec, $ns ) = $rr->latitude; $rr->latitude( 42.357990 ); $rr->latitude( 42, 21, 28.764, 'N' ); $rr->latitude( '42 21 28.764 N' ); When invoked in scalar context, latitude is returned in degrees, a negative ordinate being south of the equator. When invoked in list context, latitude is returned as a list of separate degree, minute, and second values followed by N or S as appropriate. Optional replacement values may be represented as single value, list or formatted string. Trailing zero values are optional. longitude $longitude = $rr->longitude; ($deg, $min, $sec, $ew ) = $rr->longitude; $rr->latitude( 71.014338 ); $rr->latitude( 71, 0, 51.617, 'W' ); $rr->latitude( '71 0 51.617 W' ); When invoked in scalar context, longitude is returned in degrees, a negative ordinate being west of the prime meridian. When invoked in list context, longitude is returned as a list of separate degree, minute, and second values followed by E or W as appropriate. altitude $altitude = $rr->altitude; Represents altitude, in metres, relative to the WGS 84 reference spheroid used by GPS. size $size = $rr->size; Represents the diameter, in metres, of a sphere enclosing the described entity. hp $hp = $rr->hp; Represents the horizontal precision of the data expressed as the diameter, in metres, of the circle of error. vp $vp = $rr->vp; Represents the vertical precision of the data expressed as the total spread, in metres, of the distribution of possible values. latlon ($lat, $lon) = $rr->latlon; Returns the latitude and longitude coordinate pair as signed floating-point degrees. version $version = $rr->version; Version of LOC protocol. COPYRIGHT
Copyright (c)1997 Michael Fuhr. Portions Copyright (c)2011 Dick Franks. Package template (c)2009,2012 O.M.Kolkman and R.W.Franks. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl, Net::DNS, Net::DNS::RR, RFC1876 perl v5.18.2 2014-01-16 Net::DNS::RR::LOC(3)
All times are GMT -4. The time now is 11:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy