What is >&5 ??

Hello I have a stupidy question. in below line what's meaning of >&5?

echo "$as_me:$LINENO: checking wxWidgets version" >&5
tnx in advance

Send the output to file-descriptor #5. Usually file descriptor #2 is standard error, while #1 is standard out. This is probably in the context of a very complex pipeline, where #3 and #4 are used for other things, and so only #5 is available.

Conversely, if you piped the output from the echo like this

cat  5>&1

it would send the output back to standard out.

Thanks otheus, but what is role of &?

The & is the 2nd character of >& which is just the syntax for this operation. Asking what role the & has is like asking what role the e has in "while".

That designates that 5 is a file descriptor, and not the name of a file.

Zaxon,
Look at this example to see if it makes sense.

2>&1 means "send standard error (file descriptor 2) to the same place standard output (file descriptor 1) is going."
n>&m is an operator
in this case
5>&1 is an operator
5 is file descriptor 5
1 is file descriptor 1

Hope it helps!

And you can redirect standard input as well but the other way round!

echo "This is the script's standard input"
cat <&0

Anyone please explain me what does the last line of this script do and what its significance, since the syntax is so cryptic and obscure to understand.

 exec 5<&0 < myfile
 while read line; do
 .........
 done
 exec <&5 5<&\-

Could anyone give me answer for the above?

It closes the input.

More precisely, the current standard input (usually the TTY) is copied to filedescriptor #5. The, filedescriptor #0 is opened to "myfile", so that a process (while read...) will no read from myfile instead of the TTY. The final exec restores the filedescriptors to their original state.

The same could be simply done this way:

cat myfile | while read line; do 
 ...
done