How To Use Linux Xxd Command Tutorial For Hex and Binary Operations With Example? – POFTUT

How To Use Linux Xxd Command Tutorial For Hex and Binary Operations With Example?

Linux provides a lot of tools for hexadecimal and binary manipulation. Xxd is one of the most popular tool. Xxd is generally used to create hex dump of the given file or standard input.

Help

We can list help information about xxd command with the -h option.

Help

Help

Syntax

We will use following syntax for xxd command.

Dump to Hexadecimal

A file can be dumped into hexadecimal format just providing the file name. We will dump the file named Makefile in this example.

Dump to Hexadecimal

Dump to Hexadecimal

Dump From Commands Line or Standard Input

In previous example we have dumped from a file. xxd also supports dumping from standard input or console. We will provide - to specify input as standard input. At the end of the input we will stop input with CTRL+d shortcut.

Dump From Commands Line or Standard Input

Dump From Commands Line or Standard Input

Set Start Index

While dumping from a file there may be a lot of data those we are not interested. So we simply skip them. xxd provides -s option to skip to the specified index. In this example we will skip first 5 lines and start from 6. line.

Set Start Index

Set Start Index

Set End Index

Previous example we have set the start index , we can also set the end index to limit printing data range in a file. We will use -l option with the value. In this example we set end index as 30 .

Set End Index

Set End Index

Set Column Length

xxd uses 16 as the default column length. This value can be changed with the -l option providing length value. In this example we will set column length as 12 .

Set Column Length

Set Column Length

1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)