Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Linux
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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.
  #2 (permalink)  
Old September 9th, 2012, 03: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.
  #3 (permalink)  
Old October 25th, 2012, 04: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


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 03:27 PM
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
understanding Variable use imroostercogburn C++ Programming 7 July 28th, 2006 06:15 PM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.