aboutsummaryrefslogblamecommitdiffhomepage
path: root/src/xxd.md
blob: 879a54bcd2c4f513c22dd5db570ba428205d17b9 (plain) (tree)



































                                                      
# xxd(1)

```markdown
  xxd [opts]
    -p          dump continuous hexdump
    -r          convert hexdump into binary ('revert')
    -e          dump as little endian mode
    -i          output as C array
```

## from ascii to hex stream
```markdown
  echo -n 'aabb' | xxd -p
    >> 61616262
```

## from hex stream to binary stream
```markdown
  echo -n '61616262' | xxd -p -r
    >> aabb
```

## ascii to binary
```markdown
  echo -n '\x7fELF' | xxd -p | xxd -p -r | file -p -
    >> ELF
```

## ascii to C array (hex encoded)
```markdown
  xxd -i <(echo -n '\x7fELF')
    >> unsigned char _proc_self_fd_11[] = {
    >>   0x7f, 0x45, 0x4c, 0x46
    >> };
    >> unsigned int _proc_self_fd_11_len = 4;
```