LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2010, 01:58 PM   #1
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Rep: Reputation: 65
shell script question,standard input,output,error


Code:
echo "Redirect this STDOUT to STDERR" 1>&2
cat $1 2>&1
grep -r hda6 * . 1>&2 stderr.txt
grep -r hda6 * . 2>&1 stderr.txt
grep -r hda6 * . &> stderr_and_stdout.txt
Can someone explain these commands?
 
Old 04-14-2010, 04:09 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
What happens when you run them?

Not on a Linux box ATM---so I can't try...
 
Old 04-14-2010, 04:47 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
A few quick experiments says that those commands don't make sense.

e.g. you can redirect to a file, or to another standard FD, but not both.

So--add to my earlier question: What are the commands **supposed to** do?
 
Old 04-14-2010, 11:11 PM   #4
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Original Poster
Rep: Reputation: 65
Which is the correct syntax?
Code:
cat b.c 2>&1 file1.txt
or
Code:
cat b.c>file1 2>&1

Last edited by cola; 04-14-2010 at 11:12 PM.
 
Old 04-15-2010, 01:11 AM   #5
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
The second one is correct!!
 
  


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
Connecting both standard input and output to another program so that they can interac eantoranz Linux - Software 7 06-28-2009 07:03 PM
Help on my Linux Homework ! bash shell script / input-output data etc Bebelindo Programming 2 03-03-2009 12:51 PM
Shell script question - Lynx + input variables viceroy Programming 2 07-22-2007 07:25 PM
Output and Error redirection in Shell script (MinGW) montylee Programming 6 09-08-2006 05:06 AM
utf , standard output / input and grep too Fascistchicken Linux - Software 2 11-05-2004 08:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:15 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