Tuesday, November 20, 2012

How to select lines with a numeric value in specific column greater than cetrain value in Unix

Lets say that you have a text file with 3 columns and you want to select lines that contain in column 2 a numerical value greater than certain value. Use awk to do this task:

awk '{ if ( $2 >= 1.5 ) print $0 }'

This command will print out all lines from the file that contain a numerical value greater or equal than 1.5 in the second column.

No comments:

Post a Comment