Hi,
How do I redirect standard error in Bash?
I know 2> is what you use in tcsh for redirecting standard error to a file but what is it in Bash?
What about standard output in Bash?
Thanks
Hi,
How do I redirect standard error in Bash?
I know 2> is what you use in tcsh for redirecting standard error to a file but what is it in Bash?
What about standard output in Bash?
Thanks
cat error >& output.txt
that will redirect both standard output and standard error output to output.txt
standard output is just plain old >
//edit: 2> works with stderr only
Last edited by ygfperson; 07-15-2002 at 11:57 PM.
ok thanks, now Ive moved on to the duplicate stuff where you use 2>&1 meaning 2 is the duplicate of 1
what is happening with these two similar scripts using that example?
2>&1 cat x junk 1> junk2
1> junk2 2>&1 cat x junk
Assume junk exists but file x does not exist
Thanks
This does nothing: 2>&1 because the &1 references to itself.
cat x junk 1> junk2
This will print "cat: x: No such file or directory" and prints junk to junk2(because stderr is not redirected)
Last edited by raimo; 07-16-2002 at 02:28 PM.
I am not using Dev-C++.
#!/usr/bin/env python
import sys;file=open(sys.argv[0]);print file.read();file.close()