Why does dd not output to stdout?

2

This is the command I am experiencing the issue with

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

Test output to file trial (for sanity?)

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

Environment

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

Relevant section from the dd Man page, which seems to imply outputting to the stdout file descriptor/stream is the default behavior:

      of=FILE
             write to FILE instead of stdout

Examples I have found such as in this link also imply that: AskUbuntu - How do you monitor the progress of dd?

  • Windows 10 Pro x64
  • Cygwin
  • ConEmu 170517

Pysis

Posted 2017-06-08T02:54:06.910

Reputation: 980

Answers

3

The problem might be with seek which tells dd to skip some blocks at start of its output. How do you expect it to work with stdout? In my Ubuntu the similar dd command also hangs until I hit Ctrl+C.

Solution: get rid of the seek=10 option and it should work.

Note: to skip the input use skip. Maybe this is what you really wanted.

Kamil Maciorowski

Posted 2017-06-08T02:54:06.910

Reputation: 38 429

Rats! I knew about that distinction from recent, but got confused when leaving the parameter from an example that was writing to a file rather than reading one: https://stackoverflow.com/a/5586379/1091943

Thanks!

– Pysis – 2017-06-08T03:24:22.883

Yup, changed it to skip and it worked! – Pysis – 2017-06-08T03:37:23.150

0

You have the words "of=test" at the end of the line which is telling dd to write the output to a file "test" - delete that bit and it will write to stdout.

davidgo

Posted 2017-06-08T02:54:06.910

Reputation: 49 152

1The command I am having trouble with was the first call to dd that is only lacking the of= parameter from the following invocation test, and shows no records were processed once I manually quit. I have clarified some parts of the question text accordingly. – Pysis – 2017-06-08T03:11:42.630