I have a file with two columns,
sdfsd 1.3 sdfds 3 sdfsdf 2.1 dsfsdf -1
if x is 2
I want to print sdfsdf 2.1
How to express it in awk (bash or sed is good too)
This makes you wonder:
sort -k 2 -g | awk '$2 >= 2 { print; exit }'
Tested and works on your example. If the second column is at least 2, it does not print anything.
AWK:
BEGIN { min=0 mint="" threshold=2 } { if($2 > threshold && ($2 < min || min == 0)) { min = $2 mint = $1 } } END { print mint, min }
Source: https://habr.com/ru/post/1748588/More articles:NetBeans and Tomcat virtual hosts - tomcatWhen using the C # property, if the recipient or part of it processes the underlying data (if necessary)? - c #Using a value from a private variable or from an actual property in class functions? - c #Использование классов EF POCO в качестве моделей MVC 2 (с аннотациями данных) - validationHow to remove plugin (Seed Fu) from Rails - ruby-on-railsHow can I find out which window theme I am using? - c #Плитки 2 И не найдено сопоставление для HTTP-запроса с URI - Spring -MVC - springError using MVCContrib TestHelper - unit-testingWhy does this asp.net mvc unit test fail? - unit-testing.NET Web application that can be accessed from a mobile device - language-agnosticAll Articles