On Mon, Jul 23, 2001 at 10:34:27AM +0530, [EMAIL PROTECTED] wrote: | Good Morning/Evening to all, | I guess that it is standard in Unixes that : | 0 : STDIN : keyborad | 1 : STDOUT : monitor | 2 : STDERR : error output device | | If this much can be accepted , and this is true for Linux verssions , too ,
Yes, but STDIN and STDOUT don't _have_ to be connected to the keyboard and monitor. | then how come I am given an error by my Linux machine for example : | [shyam @shyam shyam] cat < 0 | Sample | ^d | | Can not open 0 : No file or directory | [shyam @shyam shyam] | | The same occurs for 1 (STDOUT) also. With the syntax you gave, bash doesn't treat the '0' or '1' specially. Then cat looks for a file to open (with fopen() function) and there is no file named "0" (or "1") in the current directory. I'm not sure what the proper name for the "&" operator in bash is, but I think of it as an address-of operator (since its function is similar to C's address-of operator and is spelled the same). If you use that it will work : $ cat <&0 asdf asdf ^D $ (I typed the first line and it echoed the second). The more common useage is to make STDERR go to the same file as STDOUT. Ie : $ command 2>&1 > filename It redirects STDERR (2, since it is on the left hand side it is automatically a file descriptor, not a file name) to STDOUT (the 1, but you need the "address-of" it so it is known to be a file descriptor and not a filename). Then it redirects STDOUT to filename (the "> filename" part). HTH, -D