LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-28-2014, 02:05 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Rep: Reputation: 9
shell scripting - selecting a range of numbers


Hi,

I have columns like this:

Code:
      1.205405     -0.948000
      1.234942     -1.251900
      1.264480     -1.550400
      1.294017     -1.842200
      1.323555     -2.126100
      1.353092     -2.400700
      1.382630     -2.664200
      1.412167     -2.913200
      1.441705     -3.140000
      1.471242     -3.322100
      1.500780     -3.400800
      1.532708     -3.309500
      1.564636     -3.099700
      1.596564     -2.840000
I want to select the colums in a way that: first column the numbers 1.4<x<1.5
and the second column the numbers are "3.0<y<3.5"

The result should be sth like this:

Code:
      1.441705     -3.140000
      1.471242     -3.322100
I don't know how to specify the range of numbers in "awk". I'd be thankful if you help me with that.
 
Old 06-28-2014, 02:40 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Hi,

You can compare values eg. $1 < 1.5 and assign multiple conditions with && (AND) so you'll have 4 conditions in total joined with &&.
 
1 members found this post helpful.
Old 06-28-2014, 02:47 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
And you'd better be real careful with those tests for negative numbers ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To get a range of prime numbers som_kurian Programming 12 11-18-2009 04:15 AM
Scripting: How to verifiy if input matches a range of numbers? klss Linux - Software 3 03-11-2009 04:57 AM
selecting a range of files.... mjh Programming 0 03-12-2008 09:02 AM
Shell scripting - Random numbers within a range felixc Linux - Newbie 2 10-09-2005 05:41 PM
Shell scripting - Adding many numbers in an array Stingreen Linux - General 2 10-25-2004 05:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration