Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: Outputting DD results to a text file

Tags:

linux

bash

shell

I'm writing a script that tests the read and write speeds of my HDD. I've been able to output the read speeds using the hdparm command. I'm using this line to test the write speeds: dd if=/dev/zero of=/tmp/test.data bs=1k count=128k

This outputs to the window:

131072+0 records in 131072+0 records out 134217728 bytes (134 MB) copied, 1.18678 s, 113 MB/s

I tried using >> and > to output the results to the text file and these didn't work. Does anyone know how I can output my results to a text file?

like image 791
Lyle Avatar asked Jul 30 '12 13:07

Lyle


People also ask

How do you put the output of a command into a file?

Redirect Output to a File Only To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.

How do you write data to a file in Linux?

In Linux, to write text to a file, use the > and >> redirection operators or the tee command.


1 Answers

They're output to stderr, so try using 2> instead of >

dd if=/dev/zero of=/tmp/test.data bs=1k count=128k 2> output.txt
like image 125
Ben Taitelbaum Avatar answered Oct 02 '22 05:10

Ben Taitelbaum