I am a newbie in shell scripting and I am using Ubuntu-11.10. In the terminal after using exec 1>file
command, whatever commands I give to terminal, its output doesn't get shown in terminal. I know that STDOUT is getting redirected to the file, the output of those commands gets redirected to file.
My questions are here
Once I use
exec 1>file
, how can I get rid of this? i.e. How can I stop the redirection of STDOUT to file and restore the normal operation of STDOUT (i.e. redirection to terminal rather than file)?I tried using
exec 1>&-
but it didn’t work as this closes the STDOUT file descriptor.Please throw light on this entire operation of
exec 1>file
andexec 1>&-
What will happen if we close the standard file descriptors 0, 1, 2 by using
exec 0>&-
exec 1>&-
exec 2>&-
?