Skip to content

Instantly share code, notes, and snippets.

@firedfox
Created December 4, 2013 08:02
Show Gist options
  • Save firedfox/7783827 to your computer and use it in GitHub Desktop.
Save firedfox/7783827 to your computer and use it in GitHub Desktop.
#!/bin/bash
awk 'BEGIN { for (i=0;i<=16;i++) hex[sprintf("%X",i)]=i; }
{
for (i=1;i<=length($0);i++) {
c=substr($0,i,1)
if (c=="+") { printf (" "); }
else if (c=="%") {
printf ("%c",hex[substr($0,++i,1)]*16+hex[substr($0,++i,1)])
}
else { printf (c); }
}
}'
#!/bin/bash
cat /dev/stdin | od -t x | awk '{
w=split($0,linedata," ");
for (j=2;j<w+1;j++) {
for (i=7;i>0;i=i-2) {
if (substr(linedata[j],i,2) == "0d") {continue;} // "\r"
if (substr(linedata[j],i,2) == "0a") {printf "\n";continue;} // "\n"
if (substr(linedata[j],i,2) != "00") {printf "%" ;printf toupper(substr(linedata[j],i,2));}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment