Skip to main content
added 91 characters in body; edited title
Source Link
Gareth
  • 18.9k
  • 15
  • 58
  • 69

linux Linux shell utils: convert a list of hexhexadecimals to a list of decimals

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

Example: file1

 0x59999
 0x5acdc
 0xffeff

I want to start

$ cat file1 | util | cat >file2

$ cat file1 | util | cat >file2

and get file2 with smthsomething like:

 1021489
 1249230
 3458080

(numbersThe numbers in example output are random, as I cantcan't convert sosuch long hex numbers to decdecimal)

UpdUPDATE: perl I solved this with the following Perl command: perl -pe '$_=hex;$_.="\n"'. Can anybody do it better?

perl -pe '$_=hex;$_.="\n"'

Is there a better solution? The real task is a sorting ofneeding to be able to sort hex numbers.

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

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.

Linux shell utils: convert a list of hexadecimals to a list of decimals

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

Example: file1

 0x59999
 0x5acdc
 0xffeff

I want to start

$ cat file1 | util | cat >file2

and get file2 with something like:

 1021489
 1249230
 3458080

(The numbers in example output are random, as I can't convert such long hex numbers to decimal)

UPDATE: I solved this with the following Perl command:

perl -pe '$_=hex;$_.="\n"'

Is there a better solution? The real task is needing to be able to sort hex numbers.

cant
Source Link
osgx
  • 6.9k
  • 8
  • 58
  • 71

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 cancant convert so long hex to dec)

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

The real task is a sorting of hex numbers.

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 output are random, as I can 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.

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.

Source Link
osgx
  • 6.9k
  • 8
  • 58
  • 71

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

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 output are random, as I can 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.