Answers: <p>Problem solved:</p>
  <p>It's because of endianess of output.</p>
  <p>There is an option <code>--endian</code> which by default is <code>little</code>.</p>
  <p>The example string was <code>cá</code>, which translates to <code>63 C3 A1</code> <code>utf-8</code> encoded:</p>
  <pre><code>~ $ echo -n cá | od --endian=big -x
  0000000 63c3 a100
  0000003
  </code></pre>
  <p>(The <code>-n</code> prevents <code>\n</code> in the end of string, making last byte <code>00</code>)</p>
  <p>So it's exactly the same output, but with bytes inverted:</p>
  <pre><code>~ $ echo -n cá | od --endian=little -x
  0000000 c363 00a1
  0000003
  </code></pre>
  <p>(<code>c363</code> instead of <code>63c3</code> and so forth).</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-10-31T03:04:26.717Z
Answers: 2020-10-31T03:04:26.717Z
Answers: Niloct
Answers: <p>Because of endianess and other things I've settled on these two aliases I use all the time.  The important thing is <code>-t x1</code></p>
  <pre><code>alias od1='od -Ax -t x1'
  alias od2='od -Ax -t x1 -c'
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-11-02T15:22:05.287Z
Answers: `-Ax` is for accepting hex offsets in params right ? But then, the `od2`'s `-c` means `-t c` and overrides `-t x1`, so `od2` could just be `od -Ax -c`.
Answers: Niloct
Answers: CC BY-SA 4.0
Answers: 2020-11-05T18:04:32.603Z
Answers: You might like this better:  `od -ctx1`.  Or use `hexdump -C` (maybe available via `hd`), or `xxd`.  To answer the implied question in the post's title:  "Yes, it is".
Answers: jrw32982
Answers: CC BY-SA 4.0
Answers: 2020-11-12T03:22:37.817Z
Answers: @Niloct `-Ax` is to output the file offsets in hex.  `-t x1` doesn't  negate the `-c` although I see why you would think that.
Answers: Wayne Walker
Answers: CC BY-SA 4.0
Answers: 2020-11-01T16:09:07.090Z
Answers: 2020-11-01T16:09:07.090Z
Answers: Wayne Walker
Body: <p>This isn't a deploy related question, but I believe it belongs here.</p>
  <p>I've found out about the <code>od</code> tool yesterday, and began to fiddle with it.</p>
  <p>The question is about <code>utf-8</code> encoding. See the examples:</p>
  <pre><code>~ $ echo -n á | od -x
  0000000 a1c3
  0000002
  ~ $ echo -n áá | od -x
  0000000 a1c3 a1c3
  0000004
  ~ $ echo -n ác | od -x
  0000000 a1c3 0063
  0000003
  
  # This is the issue
  ~ $ echo -n cá | od -x
  0000000 c363 00a1
  0000003
  </code></pre>
  <p>So <code>á</code> translates to <code>c3 a1</code> correctly in each test besides the last, which begins with an <code>ascii</code> char. Why isn't the output of the last test <code>0063 a1c3</code> (i.e. invert the one before the last) ?</p>
  <p>I've tried to read from a <code>utf-8</code> file and the result is the same.</p>
  <p>Thanks in advance.</p>
  
Tags: <bash>
Title: od output is confusing
UserDisplayName: Niloct
ThreadText: # od output is confusing
  
  (Asked by: username_0 on 2020-10-30)
  
  This isn't a deploy related question, but I believe it belongs here.
  
  I've found out about the `od` tool yesterday, and began to fiddle with it.
  
  The question is about `utf-8` encoding. See the examples:
  
  ```
  ~ $ echo -n á | od -x
  0000000 a1c3
  0000002
  ~ $ echo -n áá | od -x
  0000000 a1c3 a1c3
  0000004
  ~ $ echo -n ác | od -x
  0000000 a1c3 0063
  0000003
  
  # This is the issue
  ~ $ echo -n cá | od -x
  0000000 c363 00a1
  0000003
  
  ```
  
  So `á` translates to `c3 a1` correctly in each test besides the last, which begins with an `ascii` char. Why isn't the output of the last test `0063 a1c3` (i.e. invert the one before the last) ?
  
  I've tried to read from a `utf-8` file and the result is the same.
  
  Thanks in advance.
  
  **Tags:** bash
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-10-31. Score: 1 | Accepted answer
  
  Problem solved:
  
  It's because of endianess of output.
  
  There is an option `--endian` which by default is `little`.
  
  The example string was `cá`, which translates to `63 C3 A1` `utf-8` encoded:
  
  ```
  ~ $ echo -n cá | od --endian=big -x
  0000000 63c3 a100
  0000003
  
  ```
  
  (The `-n` prevents `\n` in the end of string, making last byte `00`)
  
  So it's exactly the same output, but with bytes inverted:
  
  ```
  ~ $ echo -n cá | od --endian=little -x
  0000000 c363 00a1
  0000003
  
  ```
  
  (`c363` instead of `63c3` and so forth).
  
  
  ---
  
  ### Answer by username_1 on 2020-11-01. Score: 1
  
  Because of endianess and other things I've settled on these two aliases I use all the time. The important thing is `-t x1`
  
  ```
  alias od1='od -Ax -t x1'
  alias od2='od -Ax -t x1 -c'
  
  ```
  
  > **Comments:**
  > **username_0**: `-Ax` is for accepting hex offsets in params right ? But then, the `od2`'s `-c` means `-t c` and overrides `-t x1`, so `od2` could just be `od -Ax -c`.  
  > **username_2**: You might like this better:  `od -ctx1`.  Or use `hexdump -C` (maybe available via `hd`), or `xxd`.  To answer the implied question in the post's title:  "Yes, it is".  
  > **username_1**: @username_0 `-Ax` is to output the file offsets in hex.  `-t x1` doesn't  negate the `-c` although I see why you would think that.  
  
  ---
  
  