1

On my Termux, for example, the following can be obtained:

$ od -A n -t x1 /dev/urandom | head -n 2
 e3 5d bf 57 fb 8b 63 06 4a 18 fe 28 73 8f 3e c0
 9f 08 6b d4 2d 38 2c 68 3c 51 83 1e 71 7b 57 2b

As you can see the values are separated with space character.

SUSv2 says:

The input data is manipulated in blocks, …. Each input block will be written as transformed by each output type, one per written line, in the order that the output types were specified. If the input block size is larger than the number of bytes transformed by the output type, … the output from each of the transformations will be separated by one or more blank characters.

I omitted some unnecesary parts by replacing with '…' on the quotation above. 2004 and 2018 editions of POSIX say same things as above.

Does the specification mean that it is possible to separate each byte, word, or whatever with tabs, '\f', '\r' and any other [:blank:] (in BRE) things instead of spaces and LFs?

PS. Actually I was thinking of the most efficient and fastest way to make each byte into each line, in range of POSIXism. At first I thought od -A n -t x1 -v | tr ABCDEF abcdef | tr -Cd abcdef0123456789\\n | fold -w 2 | grep . or somethig similar would be better. Then I found out the POSIX specification saying something questionable, as above. Also how about decimals: od -A n -t u1 -v | tr -Cs 0123456789- '[\n*]' | grep . is one way, but what about not using tr -C...? Would it make it faster? That is the purpose.

2
  • 1
    The cited paragraph is a description of the output in particular for the case when you specify more than one output format. Please edit your question and describe what you want to achieve. The od command does not have options to specify the separators, but of course you can post-process the output by piping it to other tools.
    – Bodo
    Feb 16, 2021 at 11:25
  • Not POSIX, but with GNU od you can specify -w1 to get one byte per line. Feb 16, 2021 at 15:15

1 Answer 1

1

I'm sorry for lacking the research, but I've just found this:

In the POSIX locale, a blank character is either a tab or a space character.

Source. https://pubs.opengroup.org/onlinepubs/007908799/xbd/glossary.html#tag_004_000_031

Therefore only ' 's and tabs are the separators (if in POSIX locale; I don't care for other locales, at this point). I am sorry for mistaking them by space characters.

You must log in to answer this question.