Tuesday, July 19, 2011

Converting Hexa to Decimal Value in UNIX

To convert content of hexa value into decimal value in a file, you can use this function:

Example:
There is a file with this format:
              date|description|hexa1|hexa2


and We want to convert it into:
              date|description|decimal1|decimal2

Function:
          awk -F\| -v OFS='|' '{ print $1,$2,strtonum("0x"$3),strtonum("0x"$4) }' ${Filename}

No comments:

Post a Comment