February 26th, 2007, 02:27 AM
-
2 if statement
I have a file for eg abc.xyz with the following info
7411 2.3
7403 1.1
7404 1.1
7405 1.2
7406 1.2
7407 1.2
7411 1.5
7410 1.6
7411 1.5
7410 4
7411 2.3
7410 2.6
7410 9.4
7411 2
7410 2.3
7410 8.5
7412 112.1
7410 20.9
7411 20.5
7411 1.1
7410 1.5
7411 1.4
7410 1.3
7411 1.1
7411 1.1
7411 1.1
7410 1.4
7411 1.1
7410 1.5
I want to print $1 if $1=7411 and $2 > 1.0
and also print $1 if $1=7410 and $2 > 1.3
My output should contain only 7411 and 7410 with $2 conditions defined
February 26th, 2007, 02:46 AM
-
Code:
awk ' ( $1 == 7410 && $2 > 1 ) || ( $1 == 7411 && $2 > 1.3 ) ' file
February 26th, 2007, 03:12 AM
-
Thanks friend for the quick reply
February 26th, 2007, 03:45 AM
-
Small help required again
What would be the syntax if
I want to print $1 if $1=7401 to 7412 and $2 > 1.0
February 26th, 2007, 04:05 AM
-
Code:
awk ' ( $1 >= 7401 || $1 <= 7412 ) && $2 > 1 { print $1 } ' file
February 26th, 2007, 05:08 AM
-