bash - Convert Hex to Binary on large file -
I have a text file that has ~ 2.3 million lines I have a 64 character hexadecimal string per line. I am trying to read from the line in the file line and convert the hex string to binary and output to a file. I have written this simple loop down, but I know that it is not optimal and will take it forever to fulfill it.
What is a fast way to use awk for example? Is Pearl Better to Use? I just need something that is very fast.
cat /tmp/hexFile.log | While line bin = $ (echo "obase = 2; ibase = 16; $ line" | BC) bin = 'echo $ bin; Sed 's / \\\ // g'` Repeat $ bin & gt; & Gt; /tmp/binOutput.log
This works for me. #! / Usr / bin / perl while ( & gt;) {chomp; (My $ i = 0; $ i & lt; length ($ _); $ i + = 1) {printf ('% 04b', hex (substr ($ _, $ i, 1))) Print "\ n "; }
Comments
Post a Comment