Pregunta

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
¿Fue útil?

Solución

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top