Hello,

I need to search from a text file all those number from the lines which which lie in the range 1 to 120. Say I have a file with number:
1
2
3
900
1200
so on...

I want to only those lines which has numbers in the range from 1 to 120.

Regards.

Recommended Answers

All 5 Replies

awk '$1>=1 && $1<=120' file

Thanks Salem for the response. Can u suggest me a solution for finding a list of missing number from a given range say between 1 and 120. 

Regards.

Output all the numbers from the above search into one file
Generate another file containing all the numbers you expect
Use 'diff' to work out what's missing

[..]
Can u suggest me a solution for finding a list of missing number from a given range say between 1 and 120.

awk 'END {
for (i=min; i<=max; i++)
  if (!(i in x)) print i } 
{ x[$1] }
' min=1 max=120 file
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.