LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 02:58 PM   #1
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,019

Rep: Reputation: 63
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, 05:09 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

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

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

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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-15-2010, 12:11 AM   #4
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,019

Original Poster
Rep: Reputation: 63
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-15-2010 at 12:12 AM.
 
Old 04-15-2010, 02:11 AM   #5
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 02:02 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration