<>
– This operator I saw few months ago on the one site, but I don't remember what does it mean. Maybe I'm wrong and ksh has no <>
.
a<&b
– I know that this operator merge input stream a
with output stream b
. Am I right? But I don't know where I can use it. Can you get me examples?
>&-
– I know nothing about it. For example, what does 2>&-
mean?
Best Answer
From http://www.manpagez.com/man/1/ksh/:
You will find all those details by typing
man ksh
.Especially
2>&-
means: close the standard error stream, i.e. the command is no longer able to write to STDERR, which will break the standard which requires it to be writable.To understand the concept of file descriptors, (if on a Linux system) you may have a look at
/proc/*/fd
(and/or/dev/fd/*
):File descriptor 0 (aka STDIN) is used per default for reading, fd 1 (aka STDOUT) is default for writing, and fd 2 (aka STDERR) is default for error messages. (fd 3 is in this case used by
ls
to actually read that directory.)If you redirect stuff it might look like this:
Now the default descriptors do no longer point to your terminal but to the corresponding redirects. (As you see, you can also create new fds.)
One more example for
<>
:You can do such things, but you very seldom have to do so.