LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shell script question,standard input,output,error (https://www.linuxquestions.org/questions/programming-9/shell-script-question-standard-input-output-error-802021/)

cola 04-14-2010 01:58 PM

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?

pixellany 04-14-2010 04:09 PM

What happens when you run them?

Not on a Linux box ATM---so I can't try...

pixellany 04-14-2010 04:47 PM

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?

cola 04-14-2010 11:11 PM

Which is the correct syntax?
Code:

cat b.c 2>&1 file1.txt
or
Code:

cat b.c>file1 2>&1

PMP 04-15-2010 01:11 AM

The second one is correct!!


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