Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Linux
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Linux General discussion of programming the various flavors of Linux operating systems.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Linux section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 24th, 2012, 11:34 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default understanding this command

I am having troble understanding this command.
Let me know if the way I understand is correct.
Here's the command :

cat data.txt 2> output.txt 2>&1

My answer: read the error output of the data.txt file and put it in output.txt
and vise versa.

Thanks foe helping.
Reply With Quote
  #2 (permalink)  
Old September 9th, 2012, 04:45 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is just want to write the stderr and stdout at the same file.The '2' is standard error output,and the '1' is standard output.we should do some work becaus there are two data streams write to the output.txt.
I'm so sorry about my poor english.I hope you could understand what i say.
Reply With Quote
  #3 (permalink)  
Old October 25th, 2012, 05:53 PM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
Originally Posted by stranger View Post
I am having troble understanding this command.
Let me know if the way I understand is correct.
Here's the command :

cat data.txt 2> output.txt 2>&1

My answer: read the error output of the data.txt file and put it in output.txt
and vise versa.

Thanks foe helping.
The cat data.txt 2> prints the file data.txt to STDOUT and redirects the output from STDERR into the file output.txt

The 2>&1 redirects STDERR to STDOUT after cat has written its STDERR to output.txt

The result will be an empty output.txt file and data.txt echoed to STDOUT. Like this:

Code:
$ cat data.txt 
data
$ cat data.txt 2> output.txt 2>&1
data
$ cat output.txt 
$
__________________
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
command text was not set for the command objec needy Classic ASP Databases 1 April 8th, 2009 04:27 PM
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 01:57 AM
understanding Variable use imroostercogburn C++ Programming 7 July 28th, 2006 07:15 PM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM



All times are GMT -4. The time now is 10:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.