Вопрос

I have a very huge text file and I want to know how can I find the first line in which the value of a variable is bigger than 1000?

assuming that the variable and its value have only one space in between like this:

abcd 24
Это было полезно?

Решение

Find the first occurrence of abcd greater than 1000 and print the line number and matching line and quit:

$ awk '$1=="abcd" && $2>1000{print NR, $0; exit}' file

To find any variable greater than 1000 just drop the first condition:

$ awk '$2>1000{print NR, $0; exit}' file
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top