Created
December 4, 2013 08:02
-
-
Save firedfox/7783827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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); } | |
} | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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