Binary and hex in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Binary and hex in unix
# 1  
Old 09-21-2004
Question Binary and hex in unix

not much familiar with binary and hex calculation in script programming....

explaination:

binary format control the parameter turned on or off in the program stored in hex mode, the question is:

how to change 39e to 19e using the binary calculation(although i don't know the command for binary calculation)

binary format:

11 1001 1110

hex format:

39e


just want to know any command in charge of this kind of calculation, thanks in advanced.
# 2  
Old 09-21-2004
ksh can handle hex arithmetic. Try:

Code:
typeset -i16 val
val=16#39e
((val = val & 16#1ff))
echo $val


Last edited by rbatte1; 09-05-2016 at 08:15 AM.. Reason: Added CODE tags
# 3  
Old 09-22-2004
Ksh is not my favourite shell, so can someone give some example by use sh or csh?

anyway,much appreciate about the tips.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Binary File To Hex In Linux

dHi, I have the attached file(actual file can be extracted post unzipping it) & i am trying to use the following code for coversion to hex format. Starting hex value is 84 which is start of the record & termination is done using 00 00 followed by 84(hex) which i can see in the dump clearly using... (14 Replies)
Discussion started by: siramitsharma
14 Replies

2. Shell Programming and Scripting

String to HEX conversion in UNIX

i have this below string which i need to convert it to HEX. i have already tried it but it showing extra few things on it.. let me show what i have done and what is the output i am getting and what is the desired output the input string is "!\"\"\"\"\"\"\"!\"\"\"\"\"\"\"" which is... (4 Replies)
Discussion started by: vivek d r
4 Replies

3. Shell Programming and Scripting

Unix - Binary File

Hi All, I am newbie to this forum. I am also new to shell script world. I don't understand the below shell script. File Name: sendFile.sh #!/bin/bash # # This script invokes the Connect:Direct UNIX CLI # and submits a process inline to copy a file to a remote # node. # $1 is... (3 Replies)
Discussion started by: karthi
3 Replies

4. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

5. Shell Programming and Scripting

Unix Shell scripting, removing hex 0d 0a

hi, I have a file with data like this : 5963491,11926750,Policy Endorsement 1 Policy Endorsement 2 Policy Endorsement 3 Policy Endorsement 4 Policy Endorsement 5 Policy Endorsement 6 Policy Endorsement 7 5963492,11926751,Product.Quote... (10 Replies)
Discussion started by: mrsindhe87
10 Replies

6. Shell Programming and Scripting

convert hex to binary and send to variable

Folks, can anyone help with a script to convert hex to binary digits, and break the 32 bit binary into packs of 4 and send them to 8 different variables.Any help is sincerely appreciated. Thanks venu Its in korn shell...... (24 Replies)
Discussion started by: venu
24 Replies

7. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

8. Shell Programming and Scripting

Converting hex value 7C (for pipe) to CRLF in Unix

I am trying to convert a txt file that includes one long string of data. The lines are separated with hex value 7C (for pipe). I am trying to process this file using SQR (Peoplesoft) so I thought the easiest thing to do would be to replace the eol char with a CRLF in unix so I can just... (4 Replies)
Discussion started by: sfedak
4 Replies

9. Shell Programming and Scripting

binary/hex output

i want to output something like 2f 00 00 00 but i can't seem to escape characters like i'm used to in some programming languages, so with this: echo "/\0\0\0" >> outputfile i actually get 2f 5c 30 5c 30 5c 30 0a ie the \0 isn't giving me the 00 i need, and in addition it has got an... (8 Replies)
Discussion started by: peterworth
8 Replies

10. UNIX for Advanced & Expert Users

Modifying binary file by editing Hex values ?

Hi , i'm using special binary file (lotus notes) and modifying an hexadecimal address range with windows hex editor and it works fine ! The file is an AIX one and i'm forced to transfert (ftp) it before modifying it and re-transfert ! NOW i would do this directly under AIX ! I can... (4 Replies)
Discussion started by: Nicol
4 Replies
Login or Register to Ask a Question