![]() |
command xxd - how do i decode binary in ascii???
exemple:
echo "hello world" | xxd -b | cut -c 11-63 output 01101000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100 00001010 how do i get xxd to convert binary to text again? |
Quote:
Code:
$ echo "hello world" | xxd -b -c 10 |
See the -r option in man xxd
|
I don't have xxd installed
Code:
a="Hello world"Code:
bin="01101000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100 00001010" |
i know if i don't cut it it shows in ascii, but I need to revert the binary to ascii
the -r option does not work |
Quote:
Code:
-b | -bits |
OK thank you
|
If anyone has any suggestions for native commands that convert binary to ascii ;) comment!
|
I've always found it somewhat odd that the C Standard and the scanf("%i") format specifier don't support the use of 0b01000001. in the same way that you can use 0x41.
Anyway, Perl one liner found on stackexchange: Code:
$ echo AB | perl -lpe '$_=join " ", unpack"(B8)*"' |
Quote:
All files are technically "binary", which is to say that they have ones and zeros. But for instance if you have 0100 0001 which is also 0x41, this represents binary ASCII capital A. You can treat that as 65 decimal, 0x41 hex, or the binary pattern. In the end, if you have binary data bytes which fall within the printable ASCII range, you'll see ASCII characters. There is no conversion required. |
Maybe 'strtol' of Perl could be used. Something like this would be a start:
Code:
#!/usr/local/bin/perlCode:
$ xxd -b strtol.pl | cut -b 10-62 | perl ./strtol.pl |
Yes if you're writing a program the various strtoXXX() functions can be used. It seems as if the OP here wants a command line to convert in the shell. But my contention is that they do not need to convert something which is already ASCII.
|
Quote:
|
This uses bash without any external commands.
Code:
echo '01101000 01100101 01101100 01101100 01101111 00100000printf converts the base 10 to hex. echo converts the hex to ascii characters. This is the same as above except it converts non-printing characters to a dot and formats the output. The non-printing characters are 00000000 to 00011111, and 01111111. Code:
count=0 |
| All times are GMT -5. The time now is 05:02 PM. |