"&>" and "<&" token questions

Viewed 60

I'm a little confused about the <& and >& tokens and I've included an example with my question. On the bottom of my example, couldn't I just use <3 and >4 as arguments to cat? I know you can't because I've tried it but I just don't understand why not? I'm not duplicating file descriptors 3 and 4, I'm just trying to redirect input and out put from file descriptors 3 and 4. Why do I have to include the ampersand symbols in those two tokens?

#!/bin/bash

case $# in

    0)
        exec 3<&0 4<&1
        ;;

    1)
        exec 3< $1 4<&1
        ;;

    2)
        exec 3< $1 4> $2
        ;;

    *)
        echo "bad"
        return 1
        ;; 

esac

cat <&3 >&4

exec 3<&- 4<&-
1 Answers
Related