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!

Short cut (without if) 1

Status
Not open for further replies.

dickiebird

Programmer
Feb 14, 2002
758
GB
Rather than use if ...then...fi, can ksh use the comparison short-cut that's used in C ? ( using ? and : )
I do a check on a count to roll from 1 to 99 - so can I do :

cty=($cty < 99 ? cty++ : cty=1)
echo $cty

TIA

Dickie Bird (:)-)))
 
a short form of &quot;if the else&quot; can be used

[[ $cty -lt 99 ]] && (( cty+=1 )) || (( cty=1 ))

Jean Pierre.
 
ksh93 supports the ?: construct ?:

Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top