Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with if

Status
Not open for further replies.

ng1

Technical User
Aug 22, 2007
39
0
0
US
{
if ( $1 != 1 || ($2 == 2 && $3 < 15))
{ print $0 }
}

I am using the above script to try to print out certain criteria.

Here is my practice file:

14 2 5
1 3 8
12 2 12
1 9 8
5 2 18
3 3 25

Here is my desired output:

14 2 5
12 2 12
3 3 25


Here is the output I am getting:

14 2 5
12 2 12
5 2 18 this line should not print!!
3 3 25

For some reason the $3 < 15 part of my script is being ignored. I need a little help with this.

Thanks.
 
Never mind. I got my script to do what I wanted it to.
 
The evaluation of this OR logic stops as soon as the first condition is found to be true, so the second part is never tested:

[tt]$1 != 1 || ($2 == 2 && $3 < 15)[/tt]

Annihilannic.
 
Annihilannic,

Yea, I realized that after looking at the results. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top