{"id":10,"date":"2004-05-04T07:50:35","date_gmt":"2004-05-04T13:50:35","guid":{"rendered":"http:\/\/bobbeaty.com\/wp\/?p=10"},"modified":"2007-05-08T07:04:26","modified_gmt":"2007-05-08T13:04:26","slug":"unix-hex-to-decimal","status":"publish","type":"post","link":"https:\/\/bobbeaty.com\/wp\/archives\/10","title":{"rendered":"Unix Hex-to-Decimal"},"content":{"rendered":"<p>I had need to convert hex numbers from a data file I was loading into a database into decimal numbers for the database. I figured that there had to be some simple way to do this - after all, we've got decades of Unix here. And sure enough - it came through for me like a champ!<\/p>\n<p>The program is <tt>dc<\/tt> and it's easy to get it to convert a hex number to decimal:<\/p>\n<pre>\n  echo \"16 i FF p q\" | dc\n<\/pre>\n<p>returns:<\/p>\n<pre>\n  255\n<\/pre>\n<p>I simply put the variable I need into the command:<\/p>\n<pre>\n  dec=`echo \"16 i ${var} p q\" | dc`\n<\/pre>\n<p>and that's it! Nice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had need to convert hex numbers from a data file I was loading into a database into decimal numbers for the database. I figured that there had to be some simple way to do this &#8211; after all, we&#8217;ve got decades of Unix here. And sure enough &#8211; it came through for me like [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":0,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"wp:attachment":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}