Challenge
Create a console program to display each byte of a file.
Winning
Since this is code-golf, fewest bytes wins.
Rules
- Program must be a console application, meaning that it will be ran from some sort of command-line interpreter;
- Every byte must be uppercase hexadecimal, separated by a space, and it must be 2 digits; (put number 0 before it if it has 1 digit)
- File must be read using IO or alternative, and not hard-coded;
- File path must be specified as a command-line argument or a user prompt (like STDIN);
- No loopholes please;
Example
test.txt (ends with LF)
Hello World!
$ ./hexdump.exe test.txt
48 65 6C 6C 6F 20 57 6F 72 6C 64 21 0A
hello.txt
text file as an example as an input and what the expected output should be. For instance, if thehello.txt
contained simply the wordhello
with a line break, how would this be expressed in the output? Are you grouping the bytes in 16-bit,32-bit or 64-bit words? Or is each byte expressed as two-digit hex? Are spaces acceptable after each byte as hex, or after each x-bit word? Do you require an0x
pre-fix for each byte? \$\endgroup\$