Register
It is currently Tue Oct 21, 2014 10:46 am

need an ternary operator example ...


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Mon Nov 24, 2008 3:25 am   

Joined: Thu Nov 20, 2008 3:17 am
Posts: 4
hi
i need to use the ternary operator in bash ...
the variant used in the title works ,

$ echo $(( 2 == 2 ? 2+3 : 4 ))
5
$ echo $(( 3 == 2 ? 2+3 : 4 ))
4

but when i try to use strings it gives me this :

$ echo $(( 3 == 2 ? "aaa" : "bbb" ))
bash: 3 == 2 ? "aaa" : "aaa" : syntax error: operand expected (error token is ""aaa" : "aaa" ")


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP