LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-18-2016, 09:02 AM   #1
nicksu
Member
 
Registered: Dec 2012
Posts: 35

Rep: Reputation: Disabled
Why I can not redirect the standard output of dd command


I can not figure it out why it writes nothing in my /tmp/result file while I execute like this:
Code:
MyUbuntu:/etc/systemd# dd if=/dev/zero of=/dev/null bs=1M count=10 1>/tmp/result
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.00576801 s, 1.8 GB/s
MyUbuntu:/etc/systemd# cat /tmp/result 
MyUbuntu:/etc/systemd# dd if=/dev/zero of=/dev/null bs=1M count=10 2>/tmp/result
MyUbuntu:/etc/systemd# cat /tmp/result 
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.00580062 s, 1.8 GB/s
I thought it should be come out nothing in the terminal and write all the output to the file /tmp/test , but it didn't .While the 2>/tmp/result did .

It is wierd , can somebody help me out ?
 
Old 01-18-2016, 09:06 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
If you leave out the of= option dd will by default write the copied data to stdout, so that it can be piped into other commands. Writing the status output also to stdout would interfere with parsing the copied data, so the developers have decided to write the status output to stderr instead. This why redirecting stdout (1) does not give you the wanted result, but redirecting stderr (2) will.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to direct standard output from find command dyq Programming 3 03-26-2010 03:55 PM
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 03:35 PM
How do I parse the output of a command that output to standard out? gauol Programming 9 01-17-2008 01:54 PM
can't capture 'at' command standard output to a file bartoni Linux - General 3 02-28-2006 03:52 PM
How to redirect standard output of piped command to log file andrewstr Linux - General 10 02-04-2004 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration