3

Can some propose a workaround for this bug:

cat /bin/ls |xxd -g 1 -i | xxd -r
xxd: sorry, cannot seek backwards.

But if you do:

cat /bin/ls |xxd -g 1 | xxd -r

It is ok. Is this a bug?

In the past I was able to execute this, but now I am just wondering if any alternatives exists?

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
Peter Teoh
  • 6,337
  • 4
  • 42
  • 58
  • It would seem that -i is making xxd want to seek stdin backward which of course is impossible. Perhaps it did not used to do this and a more recent version started to do this. Hard to say whether it's a bug or "expected behavior" but you could certainly work around it by using a temporary file between the first and second commands. – kcraigie Oct 31 '15 at 04:49
  • It doesn't want to seek back in the input stream. It's saying it can't seek back in the output stream. The problem is `xxd -r` expects to read the default `xxd` output format, not the `xxd -i` output format. It expects to read file offsets, and it's interpreting `0xed` as an earlier offset than `0xfa` or something like that. – rob mayoff Oct 31 '15 at 06:30

1 Answers1

5

Try xxd -r -p. This works for me:

:; cat /bin/ls | xxd -g 1 -i | xxd -r -p | md5sum - /bin/ls
fd20b8459b80679cddf83adf58277264  -
fd20b8459b80679cddf83adf58277264  /bin/ls
rob mayoff
  • 375,296
  • 67
  • 796
  • 848