There can be instances when while taking care of the Linux demand line, you should display/convert content in a file in/to a questionnaire besides its form that is original decimal or octal. Gladly, there’s an command that is inbuilt device that can be used in circumstances like these.
It’s called od, as well as in this guide, we shall talk about the principles of the device with a couple clear to see examples. Please be aware that examples talked about right here happen tested on Ubuntu 16.04 LTS.
Linux od demand
The OD demand can be used to transform input into Octal structure. After is its syntax:
od [OPTION]… [FILE]…
And some tips about what the person web page claims about this:
Write an unambiguous representation, octal bytes automatically, of FILE to output that is standard. With more
than one argument that is FILE concatenate them inside detailed purchase to create the input. Without FILE, or
when FILE is -, look over standard input.
Following are examples that are q&A-styled will give you a better idea on how the od command works:
Q1. How to use the od command?
Suppose here’s the file you want to convert:
And here’s what happens when you run the command that is od it:
So automatically, the od demand converts the file into octal structure. But the tool can be forced by you to convert into other formats as well. For example, use -x to convert to ( that is hexadecimal
Similarly, you will find choices to show the input in character, drifting, and integer platforms besides.
Q2. Steps to make skip that is od?
If you want od to skip some initial bytes, then you can do that by passing the number to the -j command line option.
od -j [num] [filename]
od -j 10 file1
Q3. How to limit output bytes per line?
By default, the command that is od 32 bytes per production line. But you can customize this number using the -w option.( if you want,********)
od -w[num] [filename]
od -w2 file1
Q4. How to make output that is od?
Suppose the file you need to transform contains duplicate lines. Including:
Then automatically, od produces * in production for duplicates.
However, you can change this behavior, something which you can do by using the -v command line option.( if you want,********)
od -c -w1 -v file1
Q5. How to display byte offsets?
Byte offsets can be displayed using the -A command line option. You need to specify the format in which you want to see the offset – x for hexadecimal, o for octal, and d for decimal.
od -A[format] [filename]
od -Ad -c file1
Q6. How to limit od’s output to set number of bytes?
To limit the output that is overall a set wide range of bytes, utilize the -N choice.
od -N[num] [filename]
od -N50 file1
So you can view the general production got curtailed.
The OD demand provides many features in as a type of demand line choices. We have talked about some ones that are major. An individual will be done exercising these, check out the device’s guy web page to find out more about this.