Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting hexadecimal to decimal from a csv-like txt file

Tags:

bash

awk

i am using a bash terminal and i have a .txt file in which i got three columns of Hex numbers separated by a space. I'd like to convert them to decimal numbers. I tried the last command from here Converting hexadecimal to decimal using awk or sed but it converts the first column only, put a comma among the columns and put a 0 on the second and third columns. to have a more clear idea of what i have and what i want:

Input

30c8 ffbc 3e80        
30c8 ffbc 3e81     

Output:

12488 65468 16000
12488 65468 16001
like image 494
merlinuxxx Avatar asked Sep 19 '13 12:09

merlinuxxx


1 Answers

Another approach would be to say:

$ while read a b c; do echo $((16#$a)) $((16#$b)) $((16#$c)); done < inputfile
12488 65468 16000
12488 65468 16001
like image 151
devnull Avatar answered Sep 28 '22 12:09

devnull