parse data using sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parse data using sh script
# 1  
Old 02-04-2009
parse data using sh script

Hi,

I am a newbie to unix/shell scripting and i have a question on how to parse a txt file using perl in a sh script. I have a txt file that contains hundreds of lines with data like this....

X, Y, Latitude, Longitude
1, 142, -38.000000, -91.000000, 26.348
2, 142, 60.000000, -90.000000, 24.836
3, 142, 51.000000, -89.000000, 23.108
4, 142, -23.000000, -88.000000, 21.848
5, 142, -29.000000, -87.000000, 20.966
6, 142, 50.000000, -86.000000, 19.418
7, 142, 55.000000, -85.000000, 19.904
8, 142, 22.000000, -84.000000, 20.030
9, 142, -50.000000, -83.000000, 16.970
10, 142, 34.000000, -82.000000, 11.912
11, 142, -18.000000, -81.000000, 8.636

i am wanting to parse all lines with the latitudes between 0 90 and longitudes of 0 -179 and then place that content into another txt file....can this be done with a perl command using sh?

Thanks!
# 2  
Old 02-04-2009
it can be done with an egrep command and regex too, but yes it can be done with a perl command...

You'll want to read up on both commands (ie, man egrep and then maybe google regular expressions), but egrep allows for multiple selections within a given command, while the use of a regex within the egrep(s) would allow for it to be as vague or precise as you'd want it to be. Redirect this to an output file and away you go...
# 3  
Old 02-04-2009

You don't need perl; it's a simple awk task:

Code:
awk '$3 > -179 && $3 < 90' FILENAME > NEWFILE

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to parse data and output to csv

I am not too savvy with arrays and am assuming that what I am looking for needs arrays. This is my requirement. So I have the raw data that gets updated to a log as shown below StudentInfo: FullInfo = { Address = Newark Age = 20 Name= John } StudentInfo:... (2 Replies)
Discussion started by: sidnow
2 Replies

2. Solaris

Need command to parse data

Hi Friends, I have data like below t064266 I want output into this format t064266 Data are space delimited and i want parse third column data. Thanks (9 Replies)
Discussion started by: Jagaat
9 Replies

3. Shell Programming and Scripting

How to Parse the XML data along with the URL in Shell Script?

Hi, Can anybody help to solve this. I want to parse some xmldata along with the URL in the Shell. I'm calling the URL via the curl command Given below is my shell script file export... (7 Replies)
Discussion started by: Megala
7 Replies

4. Shell Programming and Scripting

AWK script to parse a data in a file

Hi Unix gurus.. I have a file which has below data, It has several MQ Queue statistics; QueueName= 'TEST1' CreateDate= '2009-10-30' CreateTime= '13.45.40' QueueType= Predefined QueueDefinitionType= Local QMinDepth= 0 QMaxDepth= 0 QueueName= 'TEST2' CreateDate= '2009-10-30'... (6 Replies)
Discussion started by: dd_psg
6 Replies

5. Shell Programming and Scripting

Parse data

Guys , please help me out with another AWK solution ... Input Device Physical Name : Not Visible Device Symmetrix Name : 0743 Front Director Paths (2): { ---------------------------------------------------------------------- ... (5 Replies)
Discussion started by: greycells
5 Replies

6. Shell Programming and Scripting

Parse data

hi i have a file p1.htm <div class="colorID2"> aaaa aaaa aa <br/> bbbbbbbb bbb<br/> <br/>cccc ccc ccc </div><div class="colorID1"> dddd d ddddd<br/> eeee eeee eeeeeeeeee<br/> fffff <br/>g gg<br/> (5 Replies)
Discussion started by: saw7
5 Replies

7. Shell Programming and Scripting

Parse config file data to script variable

I have a script with few pre defined variables. Also have a config file. Something like this. # config file # Define Oracle User MOD1_TAG=abcde MOD2_TAG=xyzabc MOD3_TAG=def I need to parse the config file and have each of the value copied to different variables. Please suggest what... (1 Reply)
Discussion started by: souryadipta
1 Replies

8. Shell Programming and Scripting

How to parse data?

Hi all, I have output of paction command looking like this: RELCI 0 IP address 1.2.16.3 Xmit: CURRENT Recv: WAIT_HEADER 0 congestions 2617/0 buf. sent/rec Xmit: CURRENT Recv: WAIT_HEADER 0 congestions 0/0 buf. sent/rec BUFFER Xmit: ... (6 Replies)
Discussion started by: sameucho
6 Replies

9. Shell Programming and Scripting

parse data between parenthesis using shell script

Hi I am using shell script and i need to parse the data between parenthesis.How do i do it using shell script. Ex: section(name). I want to extract name from the above string using shell script. (4 Replies)
Discussion started by: julie_s
4 Replies

10. Shell Programming and Scripting

Help!!! Shell script to parse data file.

I am faced with a :confused: tricky problem to parse a data file ( May not be a tricky problem to the scripting guru's ). Here is what I am faced with. I have a file with multiple rows of data and the rows are not of fixed length. "|" is used as a delimiters for individual columns and each row... (3 Replies)
Discussion started by: yajaykumar
3 Replies
Login or Register to Ask a Question