1

I am dealing with a large file and I would like to efficiently delete multiple rows from it using Linux command line. Each row starts with a number and I want to delete rows that start with a number between x and y, e.g. I want to get rid of rows with their first entry in a row >=1 and <=65.

Any help would be appreciated!

Sample input

62 14 54.3846 97.2284 76.2852 0.00586727 0.00448625 0.00738023   
63 11 54.14 95.816 74.8085 -0.00117792 0.0101263 -0.018456   
64 11 55.0529 95.2962 76.2127 0.00370189 -0.0266417 -0.0103687   
65 12 54.7587 97.8565 75.6593 -0.0188772 0.0199475 -0.014265   
66 6 48.6904 55.7418 84.002 -0.00401507 -0.00262484 -0.00272206   
67 1 49.3229 54.445 84.2829 0.00102564 0.00328434 0.00452383   

Desired output

66 6 48.6904 55.7418 84.002 -0.00401507 -0.00262484 -0.00272206   
67 1 49.3229 54.445 84.2829 0.00102564 0.00328434 0.00452383   
Cyrus
  • 84,225
  • 14
  • 89
  • 153

1 Answers1

2

With awk:

awk '$1 < 1 || $1 > 65' file

Output:

66 6 48.6904 55.7418 84.002 -0.00401507 -0.00262484 -0.00272206   
67 1 49.3229 54.445 84.2829 0.00102564 0.00328434 0.00452383
Cyrus
  • 84,225
  • 14
  • 89
  • 153