05-04-2005
Covert Deci to Hex (New to AWK)
Hi, I am very new to awk and would be grateful for your help.
I need to convert a file with details like this,
Wregister( 45676, 0)
Wregister( 55550, 1)
Wregister( 44000, 0)
FlipFlop( 2342, 2)
.
.
to look like this
Wregister(626C, 0)
Wregister(D8FE, 1)
Wregister(ABE0, 0)
FlipFlop( 2342, 2) -----> unchanged,name doesn't start with "Wregister("
.
.
It converts $2 in deci into hex, and then combines the previous $1 and $2 together. The (,) at the end of the numbers is a problematic one for me. It needs to be retained too.
Please help me.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
for file in `seq 1 256`; do printf "\x$file -- $file" ; done ; printf "\n"
produces the wrong output.
I want to show the ascii codes but need to output
a hexidecimal number sequence.
I know I should use awk to do this but i'm not sure how cause I forget.
what is the awk equivelant of seq... (5 Replies)
Discussion started by: JoeTheGuy
5 Replies
2. Programming
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
3. Programming
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
4. Shell Programming and Scripting
Is it possible by using awk to remove leading zeros for a hex number?
ex:
0000000011179E0A -> 11179E0A
Thank you! (4 Replies)
Discussion started by: carloszhang
4 Replies
5. UNIX for Dummies Questions & Answers
Hi All,
I have one input file seperated with Hex decimal B1 value.
And i want to process this file. And iam creating an awk script to process this file. How can I specify the Field seperator as HEX B1 in my awk.
Please help.
Thanks in advance.:) (2 Replies)
Discussion started by: psk_kumar
2 Replies
6. Shell Programming and Scripting
Hi ,
How do i found out all the number in a range ( HEX)
for example
Input is
15CF:15D2
Output needed
15CF
15D0
15D1
15D2
Thanks (2 Replies)
Discussion started by: greycells
2 Replies
7. Shell Programming and Scripting
I have a binary (hex) file I need to parse to get some data which are encoded this way:
.* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL
By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Discussion started by: sameucho
3 Replies
8. Shell Programming and Scripting
$ awk 'BEGIN{ pat111=0x1000000002E3E02; snBegin=0x1000000002E3E01; if (pat111<=snBegin) printf "a\n"}'
a
Result is not correct.
Looks like the number is too big.
Any idea?
Thx!
Please use code tags <- click the link! (2 Replies)
Discussion started by: carloszhang
2 Replies
9. HP-UX
Hi guys,
First off, i'm a complete noob to UNIX and LINUX so apologies if I don't understand the basics!
I have a file which contains a hex value of '0D' at the end of each line when I look at it in a hex viewer.
I need to change it so it contains a hex value of '0D0A0A'
I thought... (10 Replies)
Discussion started by: AndyBSG
10 Replies
10. Shell Programming and Scripting
Hi to all,
May someone help me with the following.
The awk script below is part of a bigger awk script, and this part attempts to print an Ip address that is in hex format in decimal format. I'm trying with following code but
I'm getting 0.0.0.0 and the correct answer is 192.168.140.100
... (9 Replies)
Discussion started by: Ophiuchus
9 Replies
LEARN ABOUT PHP
openssl_random_pseudo_bytes
OPENSSL_RANDOM_PSEUDO_BYTES(3) 1 OPENSSL_RANDOM_PSEUDO_BYTES(3)
openssl_random_pseudo_bytes - Generate a pseudo-random string of bytes
SYNOPSIS
string openssl_random_pseudo_bytes (int $length, [bool &$crypto_strong])
DESCRIPTION
Generates a string of pseudo-random bytes, with the number of bytes determined by the $length parameter.
It also indicates if a cryptographically strong algorithm was used to produce the pseudo-random bytes, and does this via the optional
$crypto_strong parameter. It's rare for this to be FALSE, but some systems may be broken or old.
PARAMETERS
o $length
- The length of the desired string of bytes. Must be a positive integer. PHP will try to cast this parameter to a non-null integer
to use it.
o $crypto_strong
- If passed into the function, this will hold a boolean value that determines if the algorithm used was "cryptographically
strong", e.g., safe for usage with GPG, passwords, etc. TRUE if it did, otherwise FALSE
RETURN VALUES
Returns the generated string of bytes on success, or FALSE on failure.
EXAMPLES
Example #1
openssl_random_pseudo_bytes(3) example
<?php
for ($i = -1; $i <= 4; $i++) {
$bytes = openssl_random_pseudo_bytes($i, $cstrong);
$hex = bin2hex($bytes);
echo "Lengths: Bytes: $i and Hex: " . strlen($hex) . PHP_EOL;
var_dump($hex);
var_dump($cstrong);
echo PHP_EOL;
}
?>
The above example will output something similar to:
Lengths: Bytes: -1 and Hex: 0
string(0) ""
NULL
Lengths: Bytes: 0 and Hex: 0
string(0) ""
NULL
Lengths: Bytes: 1 and Hex: 2
string(2) "42"
bool(true)
Lengths: Bytes: 2 and Hex: 4
string(4) "dc6e"
bool(true)
Lengths: Bytes: 3 and Hex: 6
string(6) "288591"
bool(true)
Lengths: Bytes: 4 and Hex: 8
string(8) "ab86d144"
bool(true)
SEE ALSO
random_bytes(3), bin2hex(3), crypt(3), mt_rand(3), uniqid(3).
PHP Documentation Group OPENSSL_RANDOM_PSEUDO_BYTES(3)