linux shell utils: convert a list of hex to list of decimals

Posted by osgx on Super User See other posts from Super User or by osgx
Published on 2010-12-27T16:08:47Z Indexed on 2010/12/27 16:56 UTC
Read the original article Hit count: 201

Filed under:
|
|

Hello

How can I convert a file with a lot hex numbers into the decimal?

Example: file1

 0x59999
 0x5acdc
 0xffeff

I want to start

$ cat file1 | util | cat >file2

and get file2 with smth like

 1021489
 1249230
 3458080

(numbers in example output are random, as I cant convert so long hex to dec)

Upd: perl : perl -pe '$_=hex;$_.="\n"'. Can anybody do it better?

The real task is a sorting of hex numbers.

© Super User or respective owner

Related posts about linux

Related posts about bash