0

I am trying to get some I/O stats about the partitions on the system using iostat command as follows:

iostat -d /dev/sda

The output appears as follows:

Linux 4.10.0-33-generic (test)  Tuesday 26 September 2017   _x86_64_    (1 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               9.35       199.58        70.14     603985     212248

Is there any way to get the output without the first line (which displays all system info)?

I have looked up many places, but could not find this option anywhere. I am not very familiar with Linux commands.

migrated from stackoverflow.com Sep 26 '17 at 4:01

This question came from our site for professional and enthusiast programmers.

1

You can pipe the standard output of your command to sed to remove the first line. For example:

iostat | sed '1d'

If you want to remove the first two lines, the command could be:

iostat | sed '1d;2d'

It could also be:

iostat | sed '1,2d'

I found a documentation for sed here: https://www.gnu.org/software/sed/manual/sed.html.

1

A way to do this with just tail:

iostat -d /dev/sda | tail -n +3

This removes the first two lines, if you truly only want the first line removed use:

iostat -d /dev/sda | tail -n +2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy