Sponsored Content
Full Discussion: 'od' help...
Top Forums Shell Programming and Scripting 'od' help... Post 302994054 by wisecracker on Saturday 18th of March 2017 08:40:59 AM
Old 03-18-2017
'od' help...

Hi guys, consider the code below and the resiluts below that.
(I am trying to do something with cygwin that only has 'od'.)
(I KNOW these are NOT arrays, just humour me here.)

Is it possible to do what 'hexdump' does in a single line with 'od' instead of having to add the line with 'echo' in it to produce the same output as that from 'hexdump' without the last whitespace?
(The last whitespace is not a problem.)
Code:
#!/bin/bash
# Arrays
echo ';lkaF;LKJ1234Rœπ∂"OIJ;LKƒ©¥V		NWOIEH.,Z`X ;O	ij' > /tmp/chars

ARRAY1=$( hexdump -v -e '1/1 "%u "' < /tmp/chars )

ARRAY2=$( od -An -tu1 < /tmp/chars )

hexdump -C <<< "$ARRAY1"

hexdump -C <<< "$ARRAY2"

ARRAY2=$( echo $ARRAY2 )

hexdump -C <<< "$ARRAY2"

OSX 10.12.3, default bash terminal.
Code:
Last login: Sat Mar 18 12:07:51 on ttys000
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./Arrays
00000000  35 39 20 31 30 38 20 31  30 37 20 39 37 20 37 30  |59 108 107 97 70|
00000010  20 35 39 20 37 36 20 37  35 20 37 34 20 34 39 20  | 59 76 75 74 49 |
00000020  35 30 20 35 31 20 35 32  20 38 32 20 31 39 37 20  |50 51 52 82 197 |
00000030  31 34 37 20 32 30 37 20  31 32 38 20 32 32 36 20  |147 207 128 226 |
00000040  31 33 36 20 31 33 30 20  33 34 20 37 39 20 37 33  |136 130 34 79 73|
00000050  20 37 34 20 35 39 20 37  36 20 37 35 20 31 39 38  | 74 59 76 75 198|
00000060  20 31 34 36 20 31 39 34  20 31 36 39 20 31 39 34  | 146 194 169 194|
00000070  20 31 36 35 20 38 36 20  39 20 39 20 37 38 20 38  | 165 86 9 9 78 8|
00000080  37 20 37 39 20 37 33 20  36 39 20 37 32 20 34 36  |7 79 73 69 72 46|
00000090  20 34 34 20 39 30 20 39  36 20 38 38 20 33 32 20  | 44 90 96 88 32 |
000000a0  35 39 20 37 39 20 39 20  31 30 35 20 31 30 36 20  |59 79 9 105 106 |
000000b0  31 30 20 0a                                       |10 .|
000000b4
00000000  20 20 20 20 20 20 20 20  20 20 20 35 39 20 31 30  |           59 10|
00000010  38 20 31 30 37 20 20 39  37 20 20 37 30 20 20 35  |8 107  97  70  5|
00000020  39 20 20 37 36 20 20 37  35 20 20 37 34 20 20 34  |9  76  75  74  4|
00000030  39 20 20 35 30 20 20 35  31 20 20 35 32 20 20 38  |9  50  51  52  8|
00000040  32 20 31 39 37 20 31 34  37 0a 20 20 20 20 20 20  |2 197 147.      |
00000050  20 20 20 20 32 30 37 20  31 32 38 20 32 32 36 20  |    207 128 226 |
00000060  31 33 36 20 31 33 30 20  20 33 34 20 20 37 39 20  |136 130  34  79 |
00000070  20 37 33 20 20 37 34 20  20 35 39 20 20 37 36 20  | 73  74  59  76 |
00000080  20 37 35 20 31 39 38 20  31 34 36 20 31 39 34 20  | 75 198 146 194 |
00000090  31 36 39 0a 20 20 20 20  20 20 20 20 20 20 31 39  |169.          19|
000000a0  34 20 31 36 35 20 20 38  36 20 20 20 39 20 20 20  |4 165  86   9   |
000000b0  39 20 20 37 38 20 20 38  37 20 20 37 39 20 20 37  |9  78  87  79  7|
000000c0  33 20 20 36 39 20 20 37  32 20 20 34 36 20 20 34  |3  69  72  46  4|
000000d0  34 20 20 39 30 20 20 39  36 20 20 38 38 0a 20 20  |4  90  96  88.  |
000000e0  20 20 20 20 20 20 20 20  20 33 32 20 20 35 39 20  |         32  59 |
000000f0  20 37 39 20 20 20 39 20  31 30 35 20 31 30 36 20  | 79   9 105 106 |
00000100  20 31 30 20 20 20 20 20  20 20 20 20 20 20 20 20  | 10             |
00000110  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000120  20 20 20 20 20 20 20 0a                           |       .|
00000128
00000000  35 39 20 31 30 38 20 31  30 37 20 39 37 20 37 30  |59 108 107 97 70|
00000010  20 35 39 20 37 36 20 37  35 20 37 34 20 34 39 20  | 59 76 75 74 49 |
00000020  35 30 20 35 31 20 35 32  20 38 32 20 31 39 37 20  |50 51 52 82 197 |
00000030  31 34 37 20 32 30 37 20  31 32 38 20 32 32 36 20  |147 207 128 226 |
00000040  31 33 36 20 31 33 30 20  33 34 20 37 39 20 37 33  |136 130 34 79 73|
00000050  20 37 34 20 35 39 20 37  36 20 37 35 20 31 39 38  | 74 59 76 75 198|
00000060  20 31 34 36 20 31 39 34  20 31 36 39 20 31 39 34  | 146 194 169 194|
00000070  20 31 36 35 20 38 36 20  39 20 39 20 37 38 20 38  | 165 86 9 9 78 8|
00000080  37 20 37 39 20 37 33 20  36 39 20 37 32 20 34 36  |7 79 73 69 72 46|
00000090  20 34 34 20 39 30 20 39  36 20 38 38 20 33 32 20  | 44 90 96 88 32 |
000000a0  35 39 20 37 39 20 39 20  31 30 35 20 31 30 36 20  |59 79 9 105 106 |
000000b0  31 30 0a                                          |10.|
000000b3
AMIGA:amiga~/Desktop/Code/Shell> _

If anyone will know this site will have that person.

TIA.
 
All times are GMT -4. The time now is 04:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy