Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Convert hexadecimal value to decimal value Post 302958423 by sam@sam on Thursday 22nd of October 2015 03:35:40 AM
Old 10-22-2015
Yes, Don your assumption are right and the output is producing correct results...let me check this cmd on my sys

---------- Post updated at 04:31 PM ---------- Previous update was at 04:25 PM ----------

Input file:
Code:
more hexconv 
2015-01-19 00:12:32 MET 00000000fbfa0000 000000009ae5cf80 014d 015d 0017 003c 0362de20 0001 02b3 00000ecb 00000077 0000007c

2015-01-19 00:13:52 MET 00000000fc820000 00000000994c6758 014c 015d 000b 003c 08670250 0000 02b3 00000342 00000065 00000066

2015-01-19 00:14:25 MET 00000000fc550000 000000009247d3c0 014c 015d 000b 003c 00000c04 0000 02b3 00000032 0000099d 0000099d

2015-01-19 00:15:25 MET 00000000fce70000 000000009a9db6f0 014c 015d 000e 003c 00000424 0000 02b3 000002de 0000007c 0000007c

2015-01-19 00:16:25 MET 00000000fcb30000 0000000099504220 014c 015d 001d 003c 00000000 0000 02b3 0000028d 0000006a 0000006a

Code:
which awk
Missing ]
/usr/bin/awk

below is output of commands you given to me but its not generating expected results:
Code:
/usr/bin/awk 'NF{printf("%s %s %u %u %u %u %u %u %u\n",$1,$2,"0x"$4,"0x"$5,"0x"$6,"0x"$7,"0x"$8,"0x"$9,"0x"$10)}' hexconv

Code:
OUTPUT
awk: syntax error near line 1
awk: bailing out near line 1

Code:
/usr/xpg4/bin/awk 'NF{printf("%s %s %u %u %u %u %u %u %u\n",$1,$2,"0x"$4,"0x"$5,"0x"$6,"0x"$7,"0x"$8,"0x"$9,"0x"$10)}' hexconv

Code:
OUTPUT
2015-01-19 00:12:32 0 0 0 0 0 0 0
2015-01-19 00:13:52 0 0 0 0 0 0 0
2015-01-19 00:14:25 0 0 0 0 0 0 0
2015-01-19 00:15:25 0 0 0 0 0 0 0
2015-01-19 00:16:25 0 0 0 0 0 0 0

The sample output should convert hexavalues to decimals

---------- Post updated at 04:35 PM ---------- Previous update was at 04:31 PM ----------

I have tried using below cmd but not getting full results:

Code:
/usr/bin/awk '{printf("%s %s %u %u %u %u %u %u %u\n",$1,$2,"0x"$4,"0x"$5,"0x"$6,"0x"$7,"0x"$8,"0x"$9,"0x"$10)}' hexconv

Code:
OUTPUT
2015-01-19 00:12:32 %uu %uu %uu %uu %uu %uu %uu
  %uu %uu %uu %uu %uu %uu %uu
2015-01-19 00:13:52 %uu %uu %uu %uu %uu %uu %uu
  %uu %uu %uu %uu %uu %uu %uu
2015-01-19 00:14:25 %uu %uu %uu %uu %uu %uu %uu
  %uu %uu %uu %uu %uu %uu %uu
2015-01-19 00:15:25 %uu %uu %uu %uu %uu %uu %uu
  %uu %uu %uu %uu %uu %uu %uu
2015-01-19 00:16:25 %uu %uu %uu %uu %uu %uu %uu

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Convert hexadecimal to decimal base

Hello ! Does anyone knows how can I convert hexadecimal to decimal base in the ksh or csh script ?? Thanks ! Witt (1 Reply)
Discussion started by: witt
1 Replies

2. Shell Programming and Scripting

Decimal to Hexadecimal conversion

Hi frnds :) I need a small help... I have a very long file containing 20 digits decimal number which i want to convert into the corresponding 16 digit hexadecimal values. File looks like.... 11908486672755551741 05446378739602232559 04862605079740156652 . . . I tried the script for i... (7 Replies)
Discussion started by: vanand420
7 Replies

3. Shell Programming and Scripting

need script to convert number in hexadecimal

hi , i need a script to convert number into hexadecimal base for example: 237=>ED it s very important for me thank you in advance for you help (5 Replies)
Discussion started by: mips
5 Replies

4. UNIX for Dummies Questions & Answers

Hexadecimal to Decimal

Hi all, I have a small script to convert my HexaDecimal Input to Decimal as output. #!/bin/ksh hd=00208060 dec=`printf %d $hd` echo $dec Output of the above program: printf: 00208060 not completely converted 16 But my expected output is "2130016". How can i acheive this. I... (2 Replies)
Discussion started by: Arunprasad
2 Replies

5. Shell Programming and Scripting

Convert exponential value to decimal

Hi, Here is my script to read a file into array: awk -F '+' ' # load first file into array indexed by fields 1 and 2 NR == FNR { file1nr = FNR for (i=3; i<NF; i++) { file1 = $i } I have this... (5 Replies)
Discussion started by: Sangtha
5 Replies

6. Shell Programming and Scripting

To convert file with decimal to another file with Hexadecimal

I have a text file of alphanumeric values listed one by one. I have to convert them to hexadecimal equivalents for each character seperated by ":" in Unix bash shell script. For example, 12345678 has to be converted to 31:32:33:34:35:36:37:38 (10 Replies)
Discussion started by: mathie
10 Replies

7. Shell Programming and Scripting

NAWK conversion of hexadecimal input to decimal output via printf, I am close I can feel it

I have searched and the answers I have found thus far have led me to this point, so I feel I am just about there. I am trying to convert a column of hexadecimal to decimal values so that I can filter out via grep just the data I want. I was able to pull my original 3 character hex value and... (10 Replies)
Discussion started by: PCGameGuy
10 Replies

8. Shell Programming and Scripting

Convert hexadecimal value in decimal value

hi all, this is my script: #! /bin/sh minutes=$( { i2cget -f -y 0 0x51 3; } 2>&1 ) minutes=${minutes:2} hour=$( { i2cget -f -y 0 0x51 4; } 2>&1 ) hour=${hour:2} day=$( { i2cget -f -y 0 0x51 5; } 2>&1 ) day=${day:2} month=$( { i2cget -f -y 0 0x51 7; } 2>&1 ) month=${month:2} ... (6 Replies)
Discussion started by: enaud
6 Replies

9. UNIX for Dummies Questions & Answers

Convert hexa decimal to decimal

Hi, I want to convert two hexadecimal numbers to decimal using unix command line. 1cce446295197a9d6352f9f223a9b698 fc8f99ac06e88c4faf669cf366f60d I tried using `echo "ibase=16; $no |bc` printf '%x\n' "1cce446295197a9d6352f9f223a9b698" but it doesn't work for such big number it... (4 Replies)
Discussion started by: sudhakar T
4 Replies

10. Programming

Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy