bash Linux:将 DD 结果输出到文本文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11722365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 02:54:26  来源:igfitidea点击:

Linux: Outputting DD results to a text file

linuxbashshell

提问by Lyle

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

我正在编写一个脚本来测试我的硬盘的读写速度。我已经能够使用 hdparm 命令输出读取速度。我正在使用这条线来测试写入速度: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

131072+0 记录在 131072+0 记录出 复制 134217728 字节 (134 MB),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?

我尝试使用 >> 和 > 将结果输出到文本文件,但这些都不起作用。有谁知道如何将结果输出到文本文件?

回答by Ben Taitelbaum

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

它们输出到标准错误,所以尝试使用2>而不是>

dd if=/dev/zero of=/tmp/test.data bs=1k count=128k 2> output.txt

回答by user1277476

dd's good for sequential writes, but also check into iozone and bonnie. Seeks within a track tend to be far faster than seeks from one track to another, so random I/O can be very different from sequential.

dd 适用于顺序写入,但也适用于 iozone 和 bonnie。轨道内的查找往往比从一个轨道到另一个轨道的查找快得多,因此随机 I/O 可能与顺序非常不同。