awk to select 2D data bins


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk to select 2D data bins
# 1  
Old 07-19-2017
awk to select 2D data bins

I wish to use AWK to do something akin: Select all 2D data with 1<$1<2 and -7.5<$2<-6.5

But it's not working

Code:
awk 'END {print ($1<=2&&$1>=1&&$2<=-6.5&&$2>=-7.5)}' bla


Data:
Code:
-1.06897 -8.04482 -61.469
-1.13613 -8.04482 -61.2271
-1.00182 -8.04482 -61.2081
-1.06897 -8.13518 -60.8544
-1.00182 -8.13518 -60.6984
-0.93466 -8.04482 -60.5836
-1.13613 -8.13518 -60.496
-1.20329 -8.04482 -60.4121
-1.06897 -7.95445 -60.1609
-0.93466 -8.13518 -60.1215
-1.13613 -7.95445 -60.0277
-1.00182 -7.95445 -59.7979
-0.867504 -8.04482 -59.7306
-1.20329 -8.13518 -59.6574
-0.867504 -8.13518 -59.2955
-1.20329 -7.95445 -59.2756
-0.93466 -7.95445 -59.0925
-1.27044 -8.04482 -59.0918
-0.800347 -7.05077 -59.0633
-0.73319 -7.05077 -58.8337
-0.800347 -6.9604 -58.8034
-0.800347 -8.04482 -58.7441
-1.27044 -8.13518 -58.4938

Any suggestion what's wrong in my command, I've been breaking my head over this.

Last edited by Scott; 07-19-2017 at 08:40 AM.. Reason: Added code tags around data
# 2  
Old 07-19-2017
Hello chrisjorg,

Could you please try to remove END section from your command once. END section will only be executed at the last when file got processed. So it will only look for the last line, try removing it and one more thing remove the print command also and only mention condition here as if condition is TRUE then by default action awk will do is printing of the specific line whose condition gets satisfied.

Thanks,
R. Singh
# 3  
Old 07-19-2017
Actually, howsoever you code it, none of your data lines in post#1 will satisfy your conditions and will be printed...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Select last update data based on file name

Hi All, I need to remove all files except the most update data based on date on filename Input data_AIDS_20150312.txt data_AIDS_20150311.txt data_AIDS_20150411.txt data_AIDS_20140312.txt the most updated data is data_AIDS_20150411.txt, so I'll remove other files. My expected output... (3 Replies)
Discussion started by: radius
3 Replies

2. Shell Programming and Scripting

awk - mixed for and if to select particular lines in a data file

Hi all, I am new to AWK and I am trying to solve a problem that is probably easy for an expert. Suppose I have the following data file input.txt: 20 35 43 20 23 54 20 62 21 20.5 43 12 20.5 33 11 20.5 89 87 21 33 20 21 22 21 21 56 87 I want to select from all lines having the... (4 Replies)
Discussion started by: naska
4 Replies

3. UNIX for Dummies Questions & Answers

Using grep to select data from file

Hello all, Once again I need to call upon the masters for help. I have a file called endpoint_data. IN that file I have groups of endpoints. However all I need from the file is this.... ENDPOINT NAME = SIPWOODSBC SIG PRI FQDN/IP ADDRESS/DOMAIN NAME = 10.xxx.xxx.xxx SIG SEC... (4 Replies)
Discussion started by: jay11789
4 Replies

4. UNIX for Dummies Questions & Answers

awk solution for taking bins

Hi all, I'm looking for an awk solution for taking bins of data set. For example, if I have two columns of data that I wish to use for a scatter plot, and it contains 5 million lines, how can I take averages of every 100 points, 1000, 10000 etc... The idea is to take bins of the 5,000,000 points... (7 Replies)
Discussion started by: torchij
7 Replies

5. Shell Programming and Scripting

Sed for select and retrieve data

I would like to recover the data from 3 text tags. These three markers are located between the tags specific location <tag1> and </tag1> knowing that they are in many places. In File.txt: <tag2>txt2</tag2> <tag3>txt3</tag3> <tag4>txt4</tag4> .... <tag1> <tag2>txt2</tag2>... (3 Replies)
Discussion started by: Amad
3 Replies

6. Shell Programming and Scripting

Calculating frequency of values within bins

Hi, I am working with files containing 2 columns in which i need to come up with the frequency/count of values in col. 2 falling within specifics binned values of col. 1. the contents of a sample file is shown below: 15 12.5 15 11.2 16 0.2 16 1.4 17 1.6 18 4.5 17 5.6 12 8.6 11 7.2 9 ... (13 Replies)
Discussion started by: ida1215
13 Replies

7. Shell Programming and Scripting

Select data from a file

Hi , I want to select data from a file .the datas in a file will be in both upper and lower case. can able to select particular data using awk. file is like Ram Selva 24332 UNIXTEAM Karthi Siva 43322 UNIXTEAM In read if i enter selva as lowercase its not displaying result. (9 Replies)
Discussion started by: boopal
9 Replies

8. Programming

sockets - can you send data while waiting on select()

Hey guys, Is it possible to have a worker thread send data out a TCP connection while another thread is waiting using using select() on that same connection? If not, then what is the correct way to maintain a connection, react to incoming data, and send data over a TCP connection? Thanks... (16 Replies)
Discussion started by: scubanarc
16 Replies

9. Shell Programming and Scripting

select data from list

Hi! My data file contains a two columns list. It looks like: 1 3.789 2 6.789 3 7.890 4 8.900 5 6.789 6 1.987 7 10.987 8 2.987 9 0.987 I would like to create a new list using the awk command, just selecting data from the second column but also printing the first column. Let say I select... (3 Replies)
Discussion started by: cris48
3 Replies

10. Shell Programming and Scripting

Displaying the data from the select query in a particular format

Hi, I have a shell script that returns 10 records for the column Name and age from a select query. Where when i store those data in retrieve_list.txt file i need to store the data in a particular format like:- $Jason$30 $Bill$23 $Roshan$25 Here is my script: 1)... (15 Replies)
Discussion started by: sachin.tendulka
15 Replies
Login or Register to Ask a Question