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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement help 1

Status
Not open for further replies.

longhair

MIS
Feb 7, 2001
889
US
good morning all,
having a bit of an issue with some logic in an HPUX 11 script.
any help would be appreciated.
Code:
...
cat /files/dsdcwhd3.txt | while read off tty tm1 tm2 tm3 tm4
  do
   if 
     [[[$tm2 = "minutes" && $tm1 > "15"] || $tm2 = "hour"]]
   then  
     print $off $tty $tm1 $tm2 >> /files/dsdcwhd3a.txt
   fi
  done
...
basically if $tm2 contains the word minutes and $tm1 is > 15 or $tm2 contains the word hour then do some work.
i've varied the # of brackets and put the variables in quotes but still do not get the anticipated output.
any suggestions?
thanks in advance.
regards,
longhair
 
change > to -gt, only one bracket, parentheses to group the and, -a for and, -o for or, whitespace after [ and before ]:

Code:
[red][ \([/red] $tm2 = "minutes" [red]-a[/red] $tm1 [red]-gt[/red] "15" [red]\) -o[/red] $tm2 = "hour"[red] ][/red]

I didn't test all of this, I'll leave that up to you.


HTH,

p5wizard
 
p5wizard,
thanks. a star for you. got it most of the way, still failing on the 'or' part.
regards,
longhair
 
all sorted.
forgot that i had to test variables to ensure that they have data before implementing if.
regards,
longhair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top