File: hex2dec

package info (click to toggle)
smstools 3.1.15-1.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,656 kB
  • ctags: 879
  • sloc: ansic: 14,857; sh: 1,195; php: 115; makefile: 48; awk: 17
file content (20 lines) | stat: -rwxr-xr-x 424 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/gawk -f

# This script reads a hex-dump and converts it to decimal numbers.
# The hex-dump must contain one or more hexadecimal numbers separated
# by spaces, colon or 0x. The lest significant end of the hex values
# is on the right side. Valid examples:
#
# echo "01 2 0x03 04:05 fa3B" | hex2dec


BEGIN {
  FS="((0x)|[ :])*";
}

{
  for (i=1; $i!=""; i++) {
    printf "%d ",strtonum("0x"$i);
  } 
  printf "\n";
}