Operating System - HP-UX
1847161 Members
6348 Online
110263 Solutions
New Discussion

Special Characters in Scripting

 
SOLVED
Go to solution

Special Characters in Scripting

Can someone explain to me what the dash represents in this example "vgdisplay 2>&-" ? I realize that I'm redirecting error messages but to what ? I've searched multiple books that I have on site and none indicate this type of redirection.

Also, can you point me to a good Web location that defines Unix shell scripting with unique items like above ?

Thanks in advance for your help.

Curtis
5 REPLIES 5
Alan Riggs
Honored Contributor
Solution

Re: Special Characters in Scripting

What that command does is actually close the stderr stream.

A good resource to look at is "man ksh" (or whatever shell you are programming in) since many of these variables are shell specific.
Kofi ARTHIABAH
Honored Contributor

Re: Special Characters in Scripting

The hyphen usually refers to the console (or screen) (that is why if in ftp you do :
get filename - it displays the file to the screen)

your man pages will explain what the special characters are. do a man sh-posix there is a lot of information on the man pages...
nothing wrong with me that a few lines of code cannot fix!
Rita C Workman
Honored Contributor

Re: Special Characters in Scripting

Well that one is similar to the standard 2>$1 which means take the standard error output and send it to the same place you are sending the standard output....
but that minus at the end has me corn'fused...

I've seen variations of this, but never ending in a minus...I'm hoping someone else knows something more on this.
James R. Ferguson
Acclaimed Contributor

Re: Special Characters in Scripting

Curtis:

Alan is correct. If you look at the man page for sh-posix [a great resource, I might add] you will see:

>&- #...The standard output is closed.

..JRF...

Re: Special Characters in Scripting

Alan's answer was correct... Found definition in the man pages for the shell.

Thanks for all your input.