The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 01:33 PM
max values amd min values devmiral Shell Programming and Scripting 12 04-19-2007 11:42 AM
Reg DB values mpkirankumar UNIX for Advanced & Expert Users 2 06-28-2006 02:57 PM
How to add two large values Omkumar Shell Programming and Scripting 5 06-10-2005 05:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-08-2006
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is online now Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,990
xor 2 values in ksh?

i have to xor two variables in ksh. how to do that?

tia,
DN2
  #2 (permalink)  
Old 11-08-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
It's easier done with Perl:

Code:
perl -le 'print (16 ^ 5)'
21

perl -le 'print (21 ^ 5)'
16
  #3 (permalink)  
Old 11-08-2006
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is online now Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,990
perl is no option.... its not on all systems
  #4 (permalink)  
Old 11-08-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Quote:
Originally Posted by DukeNuke2
perl is no option.... its not on all systems
Sorry, my bad. This can be done with KSH using built in operations (I haven't really had a need for this to date).

Code:
print $(( 16 ^ 5 ))
21

print $(( 21 ^ 5 ))
16
  #5 (permalink)  
Old 11-08-2006
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is online now Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,990
Quote:
Originally Posted by tmarikle
Sorry, my bad. This can be done with KSH using built in operations (I haven't really had a need for this to date).

Code:
print $(( 16 ^ 5 ))
21

print $(( 21 ^ 5 ))
16
this works... thank you so much!
  #6 (permalink)  
Old 11-08-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,428
A possible solution:
Code:
a=15
b=10
a_xor_b=$(perl -e "print $a^$b")     <- gives 5

Jean-Pierre.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0