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 the data from a range from 0 to 4 and the print file would look like:
1 3.789
6 1.987
8 2.987
9 0.987
Order does not matter
Thanks for your help

Hope this is not a class assignment.

This is not 100% but you should be able to figure out the fix.

awk '{ if(($2 > 0) && ($2 < 5)) { print $1" "$2}}' yourdatafile.txt
1 Like

It`s not a class assignment, I`m just new at awk.
Thanks

Or shorter:

awk '$2 > 0 && $2 < 5' file

Without an action part between braces {...} awk prints the current record by default if the condition is true.