为什么 dd 不输出到 stdout?

Pys*_*sis 4 windows cygwin bash command-line dd

这是我遇到问题的命令

username@computer /current/working/directory
$ dd if="$filename" bs=1 seek=10 count=10 conv=notrunc status=progress^C
0+0 records in
0+0 records out
0 bytes copied, 1.70242 s, 0.0 kB/s
Run Code Online (Sandbox Code Playgroud)

测试输出到文件审判(为了理智?)

username@computer /current/working/directory
$ dd if="$filename" bs=1 seek=10 count=10 conv=notrunc status=progress of=test
22+0 records in
22+0 records out
22 bytes copied, 0.0115305 s, 1.9 kB/s
Run Code Online (Sandbox Code Playgroud)

环境

username@computer  /current/working/directory
$ echo $filename
somefile.ext

username@computer /current/working/directory
$ dd --version
dd (coreutils) 8.26
Packaged by Cygwin (8.26-1)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, David MacKenzie, and Stuart Kemp.

username@computer /current/working/directory
$ echo $SHELL
/bin/bash

username@computer /current/working/directory
$ bash --version
GNU bash, version 4.4.5(1)-release (x86_64-unknown-cygwin)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

username@computer /current/working/directory
$ stty
speed 38400 baud; line = 0;
start = <undef>; stop = <undef>; lnext = ^Q;
-imaxbel
-echoe -echok -echoctl -echoke
Run Code Online (Sandbox Code Playgroud)

手册页中的相关部分dd,这似乎暗示输出到 stdout 文件描述符/流是默认行为:

      of=FILE
             write to FILE instead of stdout
Run Code Online (Sandbox Code Playgroud)

我发现的示例(例如在此链接中)也暗示:AskUbuntu - How do you Monitor the Progress of dd?

  • Windows 10 专业版 x64
  • 西格文
  • ConEmu 170517

Kam*_*ski 5

问题可能在于seek它告诉在输出开始时dd跳过一些块。您希望它如何与 一起工作?在我的 Ubuntu 中,类似的命令也会挂起,直到我点击+ 。stdoutddCtrlC

解决方案:去掉该seek=10选项,它应该可以工作。

注意:要跳过输入,请使用skip. 也许这才是你真正想要的。