{"id":14260,"date":"2014-10-14T14:55:12","date_gmt":"2014-10-14T19:55:12","guid":{"rendered":"http:\/\/bucktownbell.com\/?p=14260"},"modified":"2014-10-14T14:55:12","modified_gmt":"2014-10-14T19:55:12","slug":"linux-command-xxd","status":"publish","type":"post","link":"http:\/\/bucktownbell.com\/?p=14260","title":{"rendered":"Linux Command: xxd"},"content":{"rendered":"<blockquote><p><code><br \/>\n[rmiller@pacific]# echo \"hello world\" &gt; hello<br \/>\n[rmiller@pacific]# xxd hello<br \/>\n0000000: 6865 6c6c 6f20 776f 726c 640a hello world<\/code><\/p>\n<p>So you can use this tool to byte edit files. One rather unusual use I\u2019ve found for it is to paste in an RPM to a system that I only had serial console access to. I just ran xxd on it, copied it into the buffer, and pasted it into a file on the remote server. A quick xxd -r, and voila. RPM.<\/p><\/blockquote>\n<p>via <a href=\"http:\/\/linuxtipsblog.com\/\">Linux Tips and Tricks<\/a>.<\/p>\n<p>I recently ran across the above blog entry which is from 2010.\u00a0 All these years working with Unix systems and I never knew about this command.\u00a0 When I parse a web site to extract information it&#8217;s necessary to output clean and concise ASCII data for my downstream scripts.\u00a0 My perl scripts that html parse do filter this out but sometimes a funny character gets through.\u00a0 Normally I have been using hexedit to determine the hex code of the offending character and although it works, it&#8217;s not as elegant as the above <em>xxd<\/em> command.\u00a0 Now I can do the following:<\/p>\n<p><code>xxd offendingdatafile.txt | grep \"mystring\" | more<\/code><\/p>\n<p>The above should simply output lines containing the offending hexcode using <em>grep<\/em> if I kind of notice a unique searchable string<em> (mystring)<\/em> before the offending hex character.\u00a0 I could also:<\/p>\n<p><code>xxd offendingdatafile.txt &gt; myfile.dat<br \/>\nvi myfile.dat<\/code><\/p>\n<p>Instead of using clunky hexedit to search for mystring I can use good old vi.<\/p>\n<p>I&#8217;m sure there are lots of other uses for this utility &#8212; especially in shell scripts.\u00a0 Unix has so many commands and I utilize a subset adequate to getting whatever it is I need to do.\u00a0 Every year I pick up one or two new useful commands that are more efficient and <em>xxd<\/em> is one of them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[rmiller@pacific]# echo &#8220;hello world&#8221; &gt; hello [rmiller@pacific]# xxd hello 0000000: 6865 6c6c 6f20 776f 726c 640a hello world So you can use this tool to byte edit files. One rather unusual use I\u2019ve found for it is to paste in &hellip; <a href=\"http:\/\/bucktownbell.com\/?p=14260\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[28,283],"class_list":["post-14260","post","type-post","status-publish","format-standard","hentry","category-operating-systems","tag-linux-command","tag-tech-blog"],"_links":{"self":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/14260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14260"}],"version-history":[{"count":4,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/14260\/revisions"}],"predecessor-version":[{"id":14279,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/14260\/revisions\/14279"}],"wp:attachment":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14260"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}